#include <bits/stdc++.h>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define hell 1000000007
#define narak 998244353
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sqr(a) (a)*(a)
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define initarr(a,n,x) for (int xxx=0;xxx<n;++xxx) a[xxx]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.insert(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T, typename U> static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}
template<typename T, typename U> static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ld long double
#define pii std::pair<int, int>
#define pll std::pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<pii >
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

pii operator+(pii a, pii b)
{
    return {a.fi+b.fi,a.se+b.se};
}
pll operator+(pll a, pll b)
{
    return {a.fi+b.fi,a.se+b.se};
}
std::ostream& operator<<(std::ostream& out,pii a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::ostream& operator<<(std::ostream& out,pll a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::istream& operator>>(std::istream& in,pii &a)
{
    in>>a.fi>>a.se;
    return in;
}
std::istream& operator>>(std::istream& in,pll &a)
{
    in>>a.fi>>a.se;
    return in;
}

using namespace std;
using namespace __gnu_pbds;
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll f(ll x)
{
    if(x<10)
        return x;
    trace(x);
    int n=0;
    ll t=x;
    int firstdig=0;
    int lastdig=x%10;
    while(t>0)
    {
        ++n;
        if(t/10 == 0)
            firstdig=t%10;
        t=t/10;
    }
    trace(firstdig,lastdig);
    ll ans=9;
    for (int i = 2; i < n; ++i)
    {
        ans+=binpow(10,i-2)*9;
    }
    trace(ans);
    for (int i = 1; i <= firstdig; ++i)
    {
        if(i<firstdig)
            ans+=binpow(10,n-2);
        else{
            ans+=((x-firstdig)/10 - binpow(10,n-2)*firstdig) + 1;
        }
    }
    trace(ans);
    return ans;
}
void dog()
{
    ll l,r;
    cin>>l>>r;
    cout<<f(r)-f(l-1);
}
int main()
{
    FAST;
    int testcases=1;
    //cin>>testcases;
    for(int i=0;i<testcases;++i)
    {
        dog();
    }
    return 0;
}


#include <bits/stdc++.h>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define hell 1000000007
#define narak 998244353
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define sqr(a) (a)*(a)
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int xxx=0;xxx<n;++xxx) cin>>a[xxx]
#define initarr(a,n,x) for (int xxx=0;xxx<n;++xxx) a[xxx]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int xxx = 0;xxx<n;xxx++){int tmp;cin>>tmp;data.insert(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<typename T, typename U> static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}
template<typename T, typename U> static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ld long double
#define pii std::pair<int, int>
#define pll std::pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi >
#define vii vector<pii >
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

pii operator+(pii a, pii b)
{
    return {a.fi+b.fi,a.se+b.se};
}
pll operator+(pll a, pll b)
{
    return {a.fi+b.fi,a.se+b.se};
}
std::ostream& operator<<(std::ostream& out,pii a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::ostream& operator<<(std::ostream& out,pll a)
{
    out<<a.fi<<" "<<a.se<<endl;
    return out;
}
std::istream& operator>>(std::istream& in,pii &a)
{
    in>>a.fi>>a.se;
    return in;
}
std::istream& operator>>(std::istream& in,pll &a)
{
    in>>a.fi>>a.se;
    return in;
}

using namespace std;
using namespace __gnu_pbds;
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll f(ll x)
{
    if(x<10)
        return x;
    int n=0;
    ll t=x;
    int firstdig=0;
    int lastdig=x%10;
    while(t>0)
    {
        ++n;
        if(t/10 == 0)
            firstdig=t%10;
        t=t/10;
    }
    ll ans=9;
    for (int i = 2; i < n; ++i)
    {
        ans+=binpow(10,i-2)*9;
    }
    for (int i = 1; i <= min(firstdig,lastdig); ++i)
    {
        if(i<firstdig)
            ans+=binpow(10,n-2);
        else{
            ans+=((x-lastdig) - binpow(10,n-1)*firstdig)/10 + 1;
        }
    }
    return ans;
}
void dog()
{
    ll l,r;
    cin>>l>>r;
    cout<<f(r)-f(l-1);
}
int main()
{
    FAST;
    int testcases=1;
    //cin>>testcases;
    for(int i=0;i<testcases;++i)
    {
        dog();
    }
    return 0;
}


#include<bits/stdc++.h>                                                   //---------------------------------------------------------------

# define ll long long
# define ld long double
# define mod 1000000007
# define MAX 100005
# define pi 3.141592653589793238                                                                                //shortcut keys

# define pb push_back
# define mp make_pair
# define all(x) x.begin(),x.end()

# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------
using namespace std;
int firstdigit(ll x){
	int y;
	while(x!=0){
		y=x%10;
		x=x/10;
	}
	return y;
}
int main()
{
	ll l,r;
	cin>>l>>r;
	ll x,y;
	l--;
	if(l<=9)x=l;
	else {
		x=l/10+9;
		if(firstdigit(l)>(l%10))
		x--;
	}
	if(r<=9)y=r;
	else {
		y=r/10+9;
		if(firstdigit(r)>(r%10))
		y--;
	}
	cout<<y-x<<'\n';
	return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define clr(a) memset(a,0,sizeof(a))
#define pb push_back
#define pf push_front
#define sc1(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d %d",&x,&y)
#define sc3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define IO ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
const int N=2e5+4,M=1e7+6, OO = 0x3f3f3f3f;
const ll mod=1e9+7;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

int main()
{//IO
#ifndef ONLINE_JUDGE
    //freopen("out.txt","w",stdout);
#endif
   // cout<<(1<<3)<<endl;
   //cout<<sqrt(1000000000)*2<<endl;
    ll l,r,x,y,ans=0,a;
    cin>>l>>r;l--;
    if(l<10)ans=l;
	else{
        ans=l/10 + 9;
        a=l%10;
        while(l>9){
            l/=10;
        }
        if(l>a)ans--;
	}x=ans;
    if(r<10)ans=r;
	else{
        ans=r/10 + 9;
        a=r%10;
        while(r>9){
            r/=10;
        }
        if(r>a)ans--;
	}y=ans;
	cout<<y-x<<endl;
    return 0;
}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
ll fu = 0;
ll calculate(string s){
	if(s.length()==1) return (s[0]- '0');
	ll k = pow(10,s.length() - 2) , c =0 ;
	c = (s[0] - '0' - 1)*k;
	k/=10;
	for(int i = 1 ; i < s.length() ; i++){
		c += (s[i] - '0')*k;
		k/=10;
	}
	if(s[s.length()-1] >= s[0]) c++;
	return c;
}
ll calculate_before(ll l){
	l--;
	ll c = 0;
	while(l > 2){
		c += (pow(10,l-2)*9);
		l--;
	}
	if(l==0)
	return 0;
	if(l==2)
	return c + 18;
	else return c + 9;
}
int main(){
fcin;
	string a , b;
	cin >> a >> b;
	// cout <<
	if(a[0]==a[a.length()-1]) fu = 1;
	ll fr = calculate(a) + calculate_before(a.length());
	ll sc = calculate(b) + calculate_before(b.length()) ;
	cout << sc - fr + fu << "\n";
	// cout << sc - fr <<"\n";
	// cout << calculate_before(7);

}


/*
 * Author: TselmegKh
 * Time: 2019-08-29 23:11:25
**/
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define MAX 100005
#define pb push_back
#define mp make_pair
#define ll long long
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define debug(args...)  cerr << #args << " = "; Dbg,args; cerr << endl;
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi num;

int dp[30][3][15][15];
int sz;
int solve(int pos, bool f, int first, int last){
	if(pos == sz){
		if(first == last){
			//debug(first, last, pos);
			return 1;
		}
		return 0;
	}
	if(dp[pos][f][first][last] != -1)return dp[pos][f][first][last];
	int ans = 0;
	int mx = 0;
	if(sz < num.size()){
		mx = 9;
	}
	else{
		if(f == 0){
			mx = num[pos];
		}
		else{
			mx = 9;
		}
	}
	for(int digit = 0; digit <= mx; digit++){
		bool tmpf = f;
		int tmpfirst = first;
		if(pos == 0 && digit == 0 && sz > 1)continue;
		if(pos == 0)tmpfirst = digit;
		if(digit < mx)tmpf = 1;
		ans += solve(pos + 1, tmpf, tmpfirst, digit);
	}
	return dp[pos][f][first][last] = ans;
}
int solve(int b){
	if(b == 0){
		return 1;
	}
	num.clear();
	while(b > 0){
		num.pb(b % 10);
		b /= 10;
	}
	reverse(all(num));

	int ans = 0;
	for(int q = 1; q <= num.size(); q++){
			sz = q;
			for(int i = 0; i <= 19; i++){
				for(int j = 0; j < 2; j++){
					for(int k = 0; k < 10; k++){
						for(int l = 0; l < 10; l++){
							dp[i][j][k][l] = -1;
						}
					}
				}
			}
		ans += solve(0, 0, 0, 0);
	}

	return ans;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int l, r;
	cin >> l >> r;
	//debug(solve(l - 1));
	cout << solve(r) - solve(l - 1);
	return 0;
}


/*
 * Author: TselmegKh
 * Time: 2019-08-29 23:11:25
**/
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define MAX 100005
#define pb push_back
#define mp make_pair
#define ll long long
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define debug(args...)  cerr << #args << " = "; Dbg,args; cerr << endl;
#define int long long
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi num;

int dp[30][3][15][15];
int sz;
int solve(int pos, bool f, int first, int last){
	if(pos == sz){
		if(first == last){
			//debug(first, last, pos);
			return 1;
		}
		return 0;
	}
	if(dp[pos][f][first][last] != -1)return dp[pos][f][first][last];
	int ans = 0;
	int mx = 0;
	if(sz < num.size()){
		mx = 9;
	}
	else{
		if(f == 0){
			mx = num[pos];
		}
		else{
			mx = 9;
		}
	}
	for(int digit = 0; digit <= mx; digit++){
		bool tmpf = f;
		int tmpfirst = first;
		if(pos == 0 && digit == 0 && sz > 1)continue;
		if(pos == 0)tmpfirst = digit;
		if(digit < mx)tmpf = 1;
		ans += solve(pos + 1, tmpf, tmpfirst, digit);
	}
	return dp[pos][f][first][last] = ans;
}
int solve(int b){
	if(b == 0){
		return 1;
	}
	num.clear();
	while(b > 0){
		num.pb(b % 10);
		b /= 10;
	}
	reverse(all(num));

	int ans = 0;
	for(int q = 1; q <= num.size(); q++){
			sz = q;
			for(int i = 0; i <= 19; i++){
				for(int j = 0; j < 2; j++){
					for(int k = 0; k < 10; k++){
						for(int l = 0; l < 10; l++){
							dp[i][j][k][l] = -1;
						}
					}
				}
			}
		ans += solve(0, 0, 0, 0);
	}

	return ans;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int l, r;
	cin >> l >> r;
	//debug(solve(l - 1));
	cout << solve(r) - solve(l - 1);
	return 0;
}


/*
 * Author: TselmegKh
 * Time: 2019-08-29 23:11:25
**/
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define MAX 100005
#define pb push_back
#define mp make_pair
#define ll long long
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define debug(args...)  cerr << #args << " = "; Dbg,args; cerr << endl;
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vi num;

int dp[30][3][15][15];
int sz;
int solve(int pos, bool f, int first, int last){
	if(pos == sz){
		if(first == last){
			//debug(first, last, pos);
			return 1;
		}
		return 0;
	}
	if(dp[pos][f][first][last] != -1)return dp[pos][f][first][last];
	int ans = 0;
	int mx = 0;
	if(sz < num.size()){
		mx = 9;
	}
	else{
		if(f == 0){
			mx = num[pos];
		}
		else{
			mx = 9;
		}
	}
	for(int digit = 0; digit <= mx; digit++){
		bool tmpf = f;
		int tmpfirst = first;
		if(pos == 0 && digit == 0 && sz > 1)continue;
		if(pos == 0)tmpfirst = digit;
		if(digit < mx)tmpf = 1;
		ans += solve(pos + 1, tmpf, tmpfirst, digit);
	}
	return dp[pos][f][first][last] = ans;
}
int solve(int b){
	num.clear();
	while(b > 0){
		num.pb(b % 10);
		b /= 10;
	}
	reverse(all(num));

	int ans = 0;
	for(int q = 1; q <= num.size(); q++){
			sz = q;
			for(int i = 0; i <= 19; i++){
				for(int j = 0; j < 2; j++){
					for(int k = 0; k < 10; k++){
						for(int l = 0; l < 10; l++){
							dp[i][j][k][l] = -1;
						}
					}
				}
			}
		ans += solve(0, 0, 0, 0);
	}

	return ans;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int l, r;
	cin >> l >> r;
	cout << solve(r) - solve(l - 1);
	return 0;
}


/*
 * In The Name Of ALLAH
 * created by Harolinch
 */
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <list>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <numeric>

#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <memory.h>
#include <ctype.h>
#include <string.h>
using namespace std;

typedef long long lint;

typedef vector<lint> vecl;

#define	elin			'\n'

#define rep(i, a, n)	for(int i = a; i<=n; i++)

class Solution {
public:

    void solve(std::istream& in, std::ostream& out) {
        vecl pow(19, 0);
        pow[0] = 1;
        rep(i, 1, 18) pow[i] = pow[i - 1] * 10;

        lint l, r;
        in >> l >> r;

        lint ans = 0;
        rep(len, 0, 17){
            rep(dig, 1, 9){
                lint lo = dig * pow[len];
                lint hi = (dig + 1) * pow[len] - 1;
                lo = max(l, lo);
                hi = min(r, hi);
                while(lo % 10 != dig) lo++;
                while((hi % 10 + 10) % 10 != dig) hi--;
                if(lo <= hi) ans += (hi - lo) / 10 + 1;
            }
        }
        out << ans << elin;
        return;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    istream& in = cin;

    ostream& out = cout;

    solve(in, out);
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define pa pair<int,int>
#define ls k<<1
#define rs k<<1|1
#define inf 0x3f3f3f3f
using namespace std;
const int N=500100;
const int M=2000100;
const LL mod=1e9+7;
LL solve(LL p){
	if(p<10) return p;
	LL ans=p/10+9,k=p%10;
	while(p>=10) p/=10;
	if(p>k) ans--;
	return ans;
}
int main(){
	LL l,r;cin>>l>>r;
	cout<<solve(r)-solve(l-1)<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second
#define ar array
#define del 1e-8

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 998244353;
const int N=2005;

ll fun(ll x){
ll ans=0;ll pow=1;
for(int i=1;i<=18;i++){
    for(int j=1;j<=9;j++){
        if(i==1){
            if(j<=x)ans++;
            continue;
        }
        if(i==2){
            if(j*10+j<=x)ans++;
            continue;
        }
        ll k=j*pow+j;
        if(k>x){
            continue;
        }
        ll mn=pow/10-1;
        mn=min(mn,(x-k)/10);
        ans+=(mn+1);
    }
    pow*=10;
}

return ans;
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
    ll l,r;
    cin>>l>>r;
    cout<<fun(r)-fun(l-1)<<"\n";
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long int toint(string s)
{
	long long x=0;
	for(int i=0;i<s.length();i++)
	{
		x+=(int(s[i]-'0'))*(pow(10,(s.length()-1-i)));
	}
	return x;
}
string tos(long long int x)
{
	if(x==0)
	return "0";
	string s;
	int i;
	while(x>0)
	{
		i=x%10;
		x/=10;
		char c=char(i+'0');
		s.push_back(c);
	}
	reverse(s.begin(),s.end());
	return s;
}

int main() {
	ios_base::sync_with_stdio;
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string l,r;
	cin >> l >> r;
	int a[18];
	a[0]=0;
	a[1]=9;
	for(int i=2;i<18;i++)
	a[i]=9*(pow(10,(i-2)));

	l=tos(toint(l)-1);
	int c1=l.length();
	int c2=r.length();
	//cout << l << endl;
	long long x=0,y=0;
	if(c1<=2)
	{

		if(c1==1)
		x=l[0]-'0';
		else
		{
			x+=9;
			x+=min((l[0]-'0'),(l[1]-'0'));
		}
	}
	if(c2<=2)
	{
		if(c2==1)
		y=r[0]-'0';
		else
		{
			y+=9;
			y+=min((r[0]-'0'),(r[1]-'0'));
		}
	}
	//cout << x << " " << y << endl;

	if(c1>2)
	{

		for(int i=1;i<c1;i++)
	    x+=a[i];
		long long int e1=1;
		e1*=min(int(l[0]-'0'),int(l[c1-1]-'0'));
		for(int i=1;i<(c1-1);i++)
		e1*=(int(l[i]-'0')+1);
		x+=e1;
   }
   if(c2>2)
   {
   	for(int i=1;i<c2;i++)
	y+=a[i];
	  //cout << y << endl;

		long long int e2=1;
		e2*=min(int(r[0]-'0'),int(r[c2-1]-'0'));

		for(int i=1;i<(c2-1);i++)
		{
		 if(r[i]!='0')
		 e2*=(int(r[i]-'0')+1);
	}

		y+=e2;
		//cout << y << " " << e2 << endl;

   }
   //cout << x << " " << y << endl;
   cout << y-x << endl;

}


#include <bits/stdc++.h>
using namespace std;
long long int toint(string s)
{
	long long x=0;
	for(int i=0;i<s.length();i++)
	{
		x+=(int(s[i]-'0'))*(pow(10,(s.length()-1-i)));
	}
	return x;
}
string tos(long long int x)
{
	string s;
	int i;
	while(x>0)
	{
		i=x%10;
		x/=10;
		char c=char(i+'0');
		s.push_back(c);
	}
	reverse(s.begin(),s.end());
	return s;
}

int main() {
	ios_base::sync_with_stdio;
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	string l,r;
	cin >> l >> r;
	int a[18];
	a[0]=0;
	a[1]=9;
	for(int i=2;i<18;i++)
	a[i]=9*(pow(10,(i-2)));

	l=tos(toint(l)-1);
	int c1=l.length();
	int c2=r.length();
	//cout << l << endl;
	long long x=0,y=0;
	if(c1<=2)
	{
		if(c1==1)
		x=l[0]-'0';
		else
		{
			x+=9;
			x+=min((l[0]-'0'),(l[1]-'0'));
		}
	}
	if(c2<=2)
	{
		if(c2==1)
		y=r[0]-'0';
		else
		{
			y+=9;
			y+=min((r[0]-'0'),(r[1]-'0'));
		}
	}
	//cout << x << " " << y << endl;

	if(c1>2)
	{

		for(int i=1;i<c1;i++)
	    x+=a[i];
		long long int e1=1;
		e1*=min(int(l[0]-'0'),int(l[c1-1]-'0'));
		for(int i=1;i<(c1-1);i++)
		e1*=(int(l[i]-'0')+1);
		x+=e1;
   }
   if(c2>2)
   {
   	for(int i=1;i<c2;i++)
	y+=a[i];
	  //cout << y << endl;

		long long int e2=1;
		e2*=min(int(r[0]-'0'),int(r[c2-1]-'0'));

		for(int i=1;i<(c2-1);i++)
		{
		 if(r[i]!='0')
		 e2*=(int(r[i]-'0')+1);
	}

		y+=e2;
		//cout << y << " " << e2 << endl;

   }
   //cout << x << " " << y << endl;
   cout << y-x << endl;

}


#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll aayushi(ll n)
{
    if(n<10)return n;
    ll ans=(n/10)+9;
    ll r=n%10;
    ll l=n;
    while(l>=10){
        l/=10;
    }
    if(l>r)ans--;
    return ans;
}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
ll t=1;
while(t--){
  ll l,r;
  cin>>l>>r;

  cout<<aayushi(r)-aayushi(l-1);

}
return 0;
}


//  ||  || |____|  //
//  ||  ||   ||   //
//  \\__//   ||  //
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define mp make_pair
#define F first
#define S second
#define I insert
#define vll vector <ll>
#define mll map <ll,ll>
#define pb push_back
#define pf push_front
#define ub upper_bound
#define lb lower_bound
#define popf pop_front
#define popb pop_back
#define M 1000000007
#define M1 998244353
#define pi 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>(t);while(t--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define f(a, b) for (ll i = a; i < b; i++)
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
ll power(ll x,ll n) {ll result=1; while(n) {if(n%2==1) result=result*x; n=n/2; x=x*x;} return result;}
ll gcd(ll a, ll b) {if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
ll BS(ll a[],ll s,ll n,ll val) {ll mid,beg=s,end=n-1; while(beg<=end)
{mid=(beg+end)/2; if(val==a[mid]){break;} else if(val>a[mid]){beg=mid+1;}else{end=mid-1;}} return mid;}
inline ll mul(ll x,ll y,ll m){ll z=1LL*x*y;if (z>=m){z%=m;} return z;}
ll powmod(ll x,ll y,ll m){ll r=1;while(y){if(y&1){r=mul(r,x,m);}y>>=1;x=mul(x,x,m);}return r;}
using namespace std;
void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/
ll solve(ll n)
{
	if(n<=9)
		return n;
	ll ans=n/10+9;
	ll x1=n%10;
	ll x2;
	while(n>0)
	{
		x2=n%10;
		n/=10;
	}
	if(x2>x1)
		ans--;
	return ans;
}
int main()
{
    start();
    ll l,r; cin>>l>>r;
    cout<<solve(r)-solve(l-1);
    return 0;
}


//@author yash
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll f(ll x)
{

	string s=to_string(x);
	int t=s.length();
	if(t==1)
	return x;
	ll k=9;
	ll ans=0;
	for(int i=1;i<=t-1;i++)
	{
		if(i==1)
		ans+=9;
		else
		{
			ans+=k;
			k*=10;
		}
	}

		int p=s[0]-'0';
		p--;
		for(int i=1;i<=p;i++)
		{
			if(t>2)
			ans+=pow(10,t-2);
			else
			ans++;

		}
		if(s[0]<=s[t-1])
		{

		string q="";
		for(int i=1;i<s.length()-1;i++)
		{
			q+=s[i];
		}
		ll r1=0;
	//10001 1000000212 10000000000	cout<<q<<endl;
		if(q!="")
		r1=stoll(q);
		ans+=r1+1;
		}
		else
		{
			string q="";
		for(int i=1;i<s.length()-1;i++)
		{
			q+=s[i];
		}
		ll r1=0;
	//	cout<<q<<endl;
		if(q!="")
		r1=stoll(q);
		//if(r1!=0)
		ans+=r1;
		}

	return ans;
}
int main()
{
	fast();
	ll a,b;
	cin>>a>>b;
	ll ans1=f(b);
//	cout<<ans1<<endl;
	ll ans2=f(a-1);
//	cout<<ans2<<endl;
	cout<<ans1-ans2<<endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll LLINF = 9223372036854775807;
const int M = 1000000007;
const int HM = 1000000009;
const int HP = 43;
const double EPS = 1e-8;

#define int long long

int get(int n) {
    if (n < 10)
        return n;
    int ans = 0;
    int tmp = n, fst = 0;
    while (tmp) {
        fst = tmp % 10;
        tmp /= 10;
    }
    ans = n / 10 + 9;
    if (n % 10 < fst)
        --ans;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int l, r;
    cin >> l >> r;
    cout << get(r) - get(l - 1) << endl;

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll LLINF = 9223372036854775807;
const int M = 1000000007;
const int HM = 1000000009;
const int HP = 43;
const double EPS = 1e-8;

#define int long long

int get(int n) {
    if (n == 0)
        return 1;
    if (n < 10)
        return n + 1;
    if (n == 10)
        return 10;
    int ans = 0;
    int ln = 0, tmp = n, fst = 0;
    while (tmp) {
        fst = tmp % 10;
        tmp /= 10;
        ++ln;
    }
    int curr = 9;
    FOR(i, 1, ln) {
        if (i == 1) {
            ans += 10;
        } else {
            ans += curr;
            curr *= 10;
        }
    }
    ans += (fst - 1) * pow(10, ln - 2);
    if (n % 10 < fst) {
        n -= (10 + (n % 10) - fst);
        int ln1 = 0, tmp1 = n;
        while (tmp1) {
            tmp1 /= 10;
            ++ln1;
        }
        if (ln1 != ln)
            return ans;
    }
    n -= fst * pow(10, ln - 1);
    n /= 10;
    ans += n + 1;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int l, r;
    cin >> l >> r;
    cout << get(r) - get(l - 1) << endl;

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iterator>
#include <fstream>
#include <math.h>

#include <vector>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <list>
#include <bitset>

#include <random>
#include <ctime>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

typedef long long ll;
typedef long double ld;

#define FOR(i, from, to) for (int i = from; i < to; i++)
#define ROF(i, from, to) for (int i = from; i > to; i--)

const double PI = 3.141592653589793238463;
const int INF = 0x3f3f3f3f;
const int INFS = 1000000000;
const ll LLINF = 9223372036854775807;
const int M = 1000000007;
const int HM = 1000000009;
const int HP = 43;
const double EPS = 1e-8;

#define int long long

int get(int n) {
    if (n == 0)
        return 1;
    if (n < 10)
        return n + 1;
    if (n == 10)
        return 10;
    int ans = 0;
    int ln = 0, tmp = n, fst = 0;
    while (tmp) {
        fst = tmp % 10;
        tmp /= 10;
        ++ln;
    }
    int curr = 9;
    FOR(i, 1, ln) {
        if (i == 1) {
            ans += 10;
        } else {
            ans += curr;
            curr *= 10;
        }
    }
    ans += (fst - 1) * pow(10, ln - 2);
    if (n % 10 < fst) {
        n -= (10 + (n % 10) - fst);
        int tmp1 = n, fst1 = 0;
        while (tmp1) {
            tmp1 /= 10;
            fst1 = tmp1 % 10;
        }
        if (fst1 != fst)
            return ans;
    }
    n -= fst * pow(10, ln - 1);
    n /= 10;
    ans += n + 1;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int l, r;
    cin >> l >> r;
    cout << get(r) - get(l - 1) << endl;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;

    while(y>0)
    {
        if(y&1)
        {
            res=res*x;
        }
        y=y>>1;
        x=x*x;
    }
    return res;
}
ll get(ll l)
{
    if(l<=9)
    {
        return l;
    }
    ll x=l/10;
    string s=to_string(l);
    if(s[0]>s[s.length()-1])
    {
        x--;
    }
    return x+9;
}
int main()
{
    ll l,r,i,j,k;
    cin>>l>>r;
    l--;
    cout<<get(r)-get(l);
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;

    while(y>0)
    {
        if(y&1)
        {
            res=res*x;
        }
        y=y>>1;
        x=x*x;
    }
    return res;
}
int main()
{
    ll l,r,i,j,k;
    cin>>l>>r;
    l--;
    if(r<=9)
    {
        cout<<r-(l+1);
        return 0;
    }
    ll c=0,sm=1;
    string s1=to_string(l);
    string s2=to_string(r);
    ll m=s1.length();
    ll n=s2.length();

    ll mn=min(s2[n-1]-'0',s2[0]-'0');
    ll sm2=0,sm1=0;
    sm=mn;
    for(i=1;i<n-1;i++)
    {
        sm=sm*((s2[i]-'0')+1);
    }
    sm2=sm;
   // cout<<sm2<<endl;
    for(i=n-1;i>=1;i--)
    {
        sm2=sm2+9*power(10,max((i-2),(ll)0));
    }
    //cout<<sm2<<endl;

    mn=min(s1[m-1]-'0',s1[0]-'0');
    sm1=1;
    sm=mn;
    for(i=1;i<m-1;i++)
    {
        sm=sm*(s1[i]-'0');
    }
    sm1=sm;
    for(i=m-1;i>=1;i--)
    {
        sm1=sm1+9*power(10,max((i-2),(ll)0));
    }
    cout<<sm2-sm1;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;

    while(y>0)
    {
        if(y&1)
        {
            res=res*x;
        }
        y=y>>1;
        x=x*x;
    }
    return res;
}
ll get(ll l)
{
    if(l<=9)
    {
        return l;
    }
    ll x=l/10;
    string s=to_string(l);
    if(s[0]>s[s.length()-1])
    {
        x--;
    }
    return x;
}
int main()
{
    ll l,r,i,j,k;
    cin>>l>>r;
    l--;
    cout<<get(r)-get(l);
}


#include <iostream>
using namespace std;
typedef long long ll;

ll l, r, fac[20], cnt[20];

void init() {
  fac[0] = 1;
  for(int i = 1; i < 19; i++)
    fac[i] = fac[i - 1] * 10;
  cnt[1] = 9;
  for(int i = 2; i < 19; i++) {
    cnt[i] = 9 * fac[i - 2];
  }
}

ll solve(ll x) {
  ll sum = 0;
  string s = to_string(x);
  int len = s.length();
  if(len == 1)
    return x;
  for(int i = 0; i <= len - 1; i++) {
    if(i == len - 1) {
      if(s[i] - '0' >= s[0] - '0')
        sum += 1;
      break;
    }
    int now = s[i] - '0';
    if(now == 0 || (now == 1 && i == 0)) continue;
    if(i == 0)
      sum += (now - 1) * fac[len - 2 - i];
    else
      sum += now * fac[len - 2 - i];
  }
  for(int i = len - 1; i >= 1; i--) {
    sum += cnt[i];
  }
  //cout << x << ' ' << sum << endl;
  return sum;
}

int main() {
  init();
  scanf("%lld %lld", &l, &r);
  printf("%lld\n", solve(r) - solve(l - 1));
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gaurav Tiwari
 */

#include <bits/stdc++.h>
#define mod 1000000007ll
#define mod2 100000009ll
#define mod3 998244353
#define pb push_back
#define fastIO ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define readi(x) scanf("%d",&x)
#define reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define PI 3.141592653589793238462643383
#define repi(i,a,b) for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a;i>b;i--)
#define mp make_pair
#define ll long long
#define sorti(a,b) sort(a,b)
#define sortd(a,b,tp) sort(a,b,greater<tp>())
#define fi first
#define se second

using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<long double,long double>pdd;
template<class T>
using max_pq = priority_queue<T>;
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;

ll l,r;

ll find(ll n)
{
	if(n==0)
		return 0;

	if(n>=1 && n<=9)
		return n;

	ll ans=(n/10)+8;
	string str=to_string(n);
	if(str[0]<=str[str.length()-1])
		ans++;
	return ans;

}

class CLittleElephantAndInterval {
public:
	void solve(istream& cin, ostream& cout) {
		cin>>l>>r;
		cout<<find(r)-find(l-1);
	}
};

int main() {
    fastIO;
	CLittleElephantAndInterval solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
const int N=100005;
const int MOD=1e9+7;

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 int solve(int x)
{
    int ans=0,f,e,xx=x;
    if(x<10)return x;
    e=x%10;
    while(x)
    {
        f=x%10;
        x/=10;
    }
    if(f<=e)ans=9+xx/10;
    else ans=8+xx/10;
    return ans;
}
int32_t main()
{

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

int n,m;
cin>>n>>m;
cout<<solve(m)-solve(n-1);

}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
const int N=100005;
const int MOD=1e9+7;

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl

int32_t main()
{

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

string a,b;
cin>>a>>b;
int x=stoll(a);
int y=stoll(b);
int n=a.size();
int m=b.size();
int count=0;
int count2=0;
if(m==1)
{
	count+=y;
}
else
{
if(b[0]-'0'<=b[m-1]-'0')
{
	count++;

}
if(y>=9)
{
	count+=8;
}
count+=(y/10);
}
if(n==1)
{
	count2+=x;
}
else
{

if(a[0]-'0'==a[n-1]-'0')
{
	count2++;

}
if(a[0]-'0'<a[n-1]-'0')
count2++;

if(x>=9)
{
	count2+=8;
}
count2+=(x/10);
}
//cout<<count2<<endl;
cout<<count-count2;

}


#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
const int N=100005;
const int MOD=1e9+7;

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl

int32_t main()
{

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

string a,b;
cin>>a>>b;
int x=stoll(a);
int y=stoll(b);
int n=a.size();
int m=b.size();
int count=0;
if(b[0]==b[m-1])
{
	count++;
}
if(y>=9)
{
	count+=9;
}
count+=(y/10);
int count2=0;
if(a[0]==a[n-1])
{
	count2++;
}
if(x>=9)
{
	count2+=9;
}
count2+=(x/10);
cout<<count-count2;

}


 #include<bits/stdc++.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<queue>
#include<time.h>
#include <cstdio>
#include <iostream>
#include <vector>
#define ll long long
#define int long long
#define inf 0x3f3f3f3f3f
#define mods 1000000007
#define modd 998244353
#define PI acos(-1)
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define mp make_pair
#define pb push_back
#define si size()
#define E exp(1.0)
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
#define IOS ios::sync_with_stdio(false);cin.tie(0)
 using namespace std;
 ll gcd(ll a,ll b){if(a<0)a=-a;if(b<0)b=-b;return b==0?a:gcd(b,a%b);}
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);
for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll qp(ll a,ll b,ll mod){ll ans=1;if(b==0){return ans%mod;}while(b){if(b%2==1){b--;ans=ans*a%mod;}a=a*a%mod;b=b/2;}return ans%mod;}//快速幂%
ll qpn(ll a,ll b, ll p){ll ans = 1;a%=p;while(b){if(b&1){ans = (ans*a)%p;--b;}a =(a*a)%p;b >>= 1;}return ans%p;}//逆元   (分子*qp(分母,mod-2,mod))%mod;

ll fact_pow(ll n,ll p){ll res=0;while(n){n/=p;res+=n;}return res;}
ll mult(ll a,ll b,ll p)
{
    a%=p;
    b%=p;
    ll r=0,v=a;
    while(b)
    {
        if(b&1)
        {
            r=(r+v)%p;

               r=(r+p)%p;
        }
        v<<=1;
        v=(v+p)%p;
        b>>=1;
    }
    return r%p;
}
ll pow_mod(ll x,ll n,ll mod)
{
    ll res=1;
    while(n)
    {
        if(n&1)
        res=mult(res,x,mod);
        x=mult(x,x,mod);
        n>>=1;
    }
    return res;
}
ll quick_pow(ll a,ll b,ll p){ll r=1,v=a%p;while(b){if(b&1)r=mult(r,v,p);v=mult(v,v,p);b>>=1;}return r;}
bool CH(ll a,ll n,ll x,ll t)
{ll r=quick_pow(a,x,n);ll z=r;for(ll i=1;i<=t;i++){r=mult(r,r,n);if(r==1&&z!=1&&z!=n-1)return true;z=r;}return r!=1;}
bool Miller_Rabin(ll n)
{if(n<2)return false;if(n==2)return true;if(!(n&1))return false;ll x=n-1,t=0;while(!(x&1)){x>>=1;t++;}
srand(time(NULL));ll o=8;for(ll i=0;i<o;i++){ll a=rand()%(n-1)+1;if(CH(a,n,x,t))return false;}return true;}
ll exgcd(ll a,ll b,ll &x,ll &y){
    if (!b){
        x=1,y=0;
        return a;
    }
    ll ans=exgcd(b,a%b,y,x);
    y-=(a/b)*x;
    return ans;
}
ll INV(ll a,ll b){ll x,y;return exgcd(a,b,x,y),(x%b+b)%b;}
ll crt(ll x,ll p,ll mod){return INV(p/mod,mod)*(p/mod)*x;}
ll FAC(ll x,ll a,ll b)
{if(!x)return 1;ll ans=1;for(ll i=1;i<=b;i++)if(i%a)ans*=i,ans%=b;
ans=pow_mod(ans,x/b,b);for(ll i=1;i<=x%b;i++)if(i%a)ans*=i,ans%=b;return ans*FAC(x/a,a,b)%b;}
ll C(ll n,ll m,ll a,ll b)
{ll N=FAC(n,a,b),M=FAC(m,a,b),Z=FAC(n-m,a,b),sum=0,i;for(i=n;i;i=i/a)sum+=i/a;
for(i=m;i;i=i/a)sum-=i/a;for(i=n-m;i;i=i/a)sum-=i/a;return N*pow_mod(a,sum,b)%b*INV(M,b)%b*INV(Z,b)%b;}
ll exlucas(ll n,ll m,ll p)
{ll t=p,ans=0,i;for(i=2;i*i<=p;i++){ll k=1;while(t%i==0){k*=i,t/=i;}
ans+=crt(C(n,m,i,k),p,k),ans%=p;}if(t>1)ans+=crt(C(n,m,t,t),p,t),ans%=p;return ans % p;}
ll H(ll x,ll p)  //错排
{
       ll ans=0;
    if(x==0)return 1;
    x=x%(2*p);
    if(x==0)x=2*p;
    for(int i=2;i<=x;++i)
    ans=(ans*i+(i%2==0?1:-1))%p;
    return (ans+p)%p;
}

unsigned long long solve(unsigned long long x)
{
    unsigned long long ans=0,f,e,xx=x;
    if(x<10)return x;
    e=x%10;
    while(x)
    {
        f=x%10;
        x/=10;
    }
    if(f<=e)ans=9+xx/10;
    else ans=8+xx/10;
    return ans;
}
signed main()
{
    unsigned long long a,b;
    cin>>a>>b;
    cout<<solve(b)-solve(a-1)<<endl;
    return 0;
}


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/

// 12 : 38

lld rec(lld x) {

  if (x < 10)
    return x;

  if (x < 100) {
    return 18;
  }

  lld ans = 1;

  string temp = to_string(x);

  rep(i , 0 , temp.length() - 2) {

    ans *= 10;

  }

  ans *= 9;

  x =  pow(10 , temp.length() - 1) - 1;
  ans = ans + rec(x);

  return ans;
}

string s;

lld cal(lld x) {

  lld a = 1 , b = 1;
  rep(i , 1 , s.length() - 1) {
    int cur = s[i] - '0';
    a *= 10;
  }

  if (s.length() == 2) {
    // lld ans = 9;
    lld ans = 0 ;
    if (s[0] <= s[1]) {
      ans += (s[0] - '0');
    }

    else
      ans += (s[0] - '0' - 1);
    // cout << ans << "\n";
    return ans;
  }

  a *= (s[0] - 1 - '0');

  lld temp = pow(10 , s.length() - 2) , tt = 0;

  temp /= 10;

  rep(i , 1 , s.length() - 1) {
    tt += temp * (s[i] - '0');
    temp /= 10;
  }

  // b += tt;

  return (a + tt + (s[0] <= s.back()));

}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;

  lld ans = 0 , ans1 = 0;

  // cout << pow(10 , max((lld)log10(x) , 1LL)) << "\n";

  ans = rec(pow(10 , max((lld)log10(x) , 1LL)) - 1) , ans1 = rec(pow(10 , max(1LL , (lld)log10(n))) - 1);
  s = to_string(x);

  // cout << ans << " " <<  ans1 << "\n";

  ans += cal(x) ;

  s = to_string((n - 1)) ;

  ans1 += cal(n - 1);

  if (x < 10) {
    ans = x;
  }

  if (n < 10)
    ans1 = n - 1;

  // cout << ans << " " << ans1 << "\n";

  cout << ans - ans1 << "\n";

}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/

// 12 : 38

lld rec(lld x) {

  if (x < 10)
    return x;

  if (x < 100) {
    return 18;
  }

  lld ans = 1;

  string temp = to_string(x);

  rep(i , 0 , temp.length() - 2) {

    ans *= 10;

  }

  ans *= 9;

  x =  pow(10 , temp.length() - 1) - 1;
  ans = ans + rec(x);

  return ans;
}

string s;

lld cal(lld x) {

  lld a = 1 , b = 1;
  rep(i , 1 , s.length() - 1) {
    int cur = s[i] - '0';
    a *= 10;
  }

  if (s.length() == 2) {
    // lld ans = 9;
    lld ans = 0 ;
    if (s[0] <= s[1]) {
      ans += (s[0] - '0');
    }

    else
      ans += (s[0] - '0' - 1);
    // cout << ans << "\n";
    return ans;
  }

  a *= (s[0] - 1 - '0');

  lld temp = pow(10 , s.length() - 2) , tt = 0;

  temp /= 10;

  rep(i , 1 , s.length() - 1) {
    tt += temp * (s[i] - '0');
    temp /= 10;
  }

  // b += tt;

  return (a + tt + (s[0] <= s.back()));

}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;

  lld ans = 0 , ans1 = 0;

  // cout << pow(10 , max((lld)log10(x) , 1LL)) << "\n";

  ans = rec(pow(10 , max((lld)log10(x) , 1LL)) - 1) , ans1 = rec(pow(10 , max(1LL , (lld)log10(n))) - 1);
  s = to_string(x);

  // cout << ans << " " <<  ans1 << "\n";

  ans += cal(x) ;

  s = to_string((n - 1)) ;

  ans1 += cal(n - 1);

  if (x < 10) {
    ans = x;
  }

  if (n < 10)
    ans1 = n - 1;

  // cout << ans << " " << ans1 << "\n";

  cout << max(0LL , ans - ans1) << "\n";

}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/
ulld solve(ulld x)
{
  ulld ans = 0, f, e, xx = x;
  if (x < 10)return x;
  e = x % 10;
  while (x)
  {
    f = x % 10;
    x /= 10;
  }
  if (f <= e)ans = 9 + xx / 10;
  else ans = 8 + xx / 10;
  return ans;
}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;
  cout << solve(x) - solve(n) << "\n";
}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/
ulld solve(ulld x)
{
  ulld ans = 0, f, e, xx = x;
  if (x < 10)return x;
  e = x % 10;
  while (x)
  {
    f = x % 10;
    x /= 10;
  }
  if (f <= e)ans = 9 + xx / 10;
  else ans = 8 + xx / 10;
  return ans;
}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;
  cout << solve(x) - solve(n - 1) << "\n";
}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/

// 12 : 38

lld rec(lld x) {

  if (x < 10)
    return x;

  if (x < 100) {
    return 18;
  }

  lld ans = 1;

  string temp = to_string(x);

  rep(i , 0 , temp.length() - 2) {

    ans *= 10;

  }

  ans *= 9;

  x =  pow(10 , temp.length() - 1) - 1;
  ans = ans + rec(x);

  return ans;
}

string s;

lld cal(lld x) {

  lld a = 1 , b = 1;
  rep(i , 1 , s.length() - 1) {
    int cur = s[i] - '0';
    a *= 10;
  }

  if (s.length() == 2) {
    // lld ans = 9;
    lld ans = 0 ;
    if (s[0] <= s[1]) {
      ans += (s[0] - '0');
    }

    else
      ans += (s[0] - '0' - 1);
    // cout << ans << "\n";
    return ans;
  }

  a *= (s[0] - 1 - '0');

  lld temp = pow(10 , s.length() - 2) , tt = 0;

  temp /= 10;

  rep(i , 1 , s.length() - 1) {
    tt += temp * (s[i] - '0');
    temp /= 10;
  }

  // b += tt;

  return (a + tt + (s[0] <= s.back()));

}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;

  lld ans = 0 , ans1 = 0;

  // cout << pow(10 , max((lld)log10(x) , 1LL)) << "\n";

  ans = rec(pow(10 , max((lld)log10(x) , 1LL)) - 1) , ans1 = rec(pow(10 , max(1LL , (lld)log10(n))) - 1);
  s = to_string(x);

  // cout << ans << " " <<  ans1 << "\n";

  ans += cal(x) ;

  s = to_string(n) ;

  ans1 += cal(n - 1);

  if (x < 10) {
    ans = x;
  }

  if (n < 10)
    ans1 = n - 1;

  // cout << ans << " " << ans1 << "\n";

  cout << ans - ans1 << "\n";

}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/

// 12 : 38

lld rec(lld x) {

  if (x < 10)
    return x;

  if (x < 100) {
    return 18;
  }

  lld ans = 1;

  string temp = to_string(x);

  rep(i , 0 , temp.length() - 2) {

    ans *= 10;

  }

  ans *= 9;

  x =  pow(10 , temp.length() - 1) - 1;
  ans = ans + rec(x);

  return ans;
}

string s;

lld cal(lld x) {

  lld a = 1 , b = 1;
  rep(i , 1 , s.length() - 1) {
    int cur = s[i] - '0';
    a *= 10;
  }

  if (s.length() == 2) {
    // lld ans = 9;
    lld ans = 0 ;
    if (s[0] <= s[1]) {
      ans += (s[0] - '0');
    }

    else
      ans += (s[0] - '0' - 1);
    // cout << ans << "\n";
    return ans;
  }

  a *= (s[0] - 1 - '0');

  lld temp = pow(10 , s.length() - 2) , tt = 0;

  temp /= 10;

  rep(i , 1 , s.length() - 1) {
    tt += temp * (s[i] - '0');
    temp /= 10;
  }

  // b += tt;

  return (a + tt + (s[0] <= s.back()));

}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;

  lld ans = 0 , ans1 = 0;

  // cout << pow(10 , max((lld)log10(x) , 1LL)) << "\n";

  k = pow(10 , max((lld)log10(x) , 1LL)) - 1;

  m = pow(10 , max(1LL , (lld)log10(n))) - 1;

  ans = rec(pow(10 , max((lld)log10(x) , 1LL)) - 1) , ans1 = rec(pow(10 , max(1LL , (lld)log10(n))) - 1);
  s = to_string(x);

  // cout << ans << " " <<  ans1 << "\n";

  if (x != (k + 1))
    ans += cal(x) ;

  s = to_string((n - 1)) ;

  if ((m + 1) != (n))
    ans1 += cal(n - 1);

  if (x < 10) {
    ans = x;
  }

  if (n < 10)
    ans1 = n - 1;

  // cout << ans << " " << ans1 << "\n";

  cout << max(0LL , ans - ans1) << "\n";

}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*          IT IS GOING TO HAPPEN !
                because
                 I AM GOING TO MAKE IT HAPPEN !      */

// all you need is to be consistent , even in your darkest times
// i dont ever give up -- Uzumaki Naruto !

#include "bits/stdc++.h"

#define DIEHOD ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define ll long long
#define all(A) begin(A) , end(A)
#define sf(x)  scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define REP(i , n) for (int i = 0; i < n; i++)
#define pf(x)  printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pii    pair<lld , lld>
#define rep(i , a , b)  for(lld i = a; i < b ; i++)
#define reps(i , a , b) for(lld i = a ; i >= b ; i--)
#define ftc(x)  cerr << #x << ": " << x << " \n" ;
#define vvi   vector < pair <lld , lld> >
#define lcm(a,b) ((a*b)/__gcd(a,b))
#define mem(a , b) memset(a , b , sizeof(a))
#define lld long long int
#define ulld unsigned long long int
#define input lld* arr = new lld [n]
#define input1 lld* brr = new lld [n]
#define vec vector < lld >
#define pb push_back
#define ss second
#define ff first
#define inf (lld)(1e18)
#define fin -999999999999999999
#define mod 1000000007
#define umap unordered_map
#define mpp make_pair
#define finish(x) cout << x << " ";
#define tolower(s)   std::transform(s.begin(), s.end(), s.begin(),[](unsigned char c){ return std::tolower(c); });

using namespace std;

// map <lld , vector<lld>> g;
// vec v;
// map<lld , bool> vis ; lld siz = 0 , ans = 0 ;

// void dfs(lld x) {

//   vis[x] = 1;

//   for (auto i : g[x]) {
//     if (!vis[i]) {
//       dfs(i);
//     }
//   }

//   return;
// }

// lld pow1(int  a , int y) {
//   a %= mod;
//   lld  ans = 1;

//   while (y > 0) {

//     if (y & 1)
//       ans = (ans * a) % mod;

//     y = y >> 1;
//     a = (a * a) % mod;
//   }
//   return ans;
// }

// lld power(int a, int b) {
//   lld ans = 1;
//   while (b > 0) {
//     if (b & 1) ans = ans * a;
//     b = b >> 1;
//     a = a * a;
//   }
//   return ans;
// }

// bool isPrime(lld n) {
//   if (n <= 1)  return false;
//   if (n <= 3)  return true;
//   if (n % 2 == 0 || n % 3 == 0) return false;

//   lld p = sqrt(n);

//   for (lld i = 5; i <= p ; i = i + 6)
//     if (n % i == 0 || n % (i + 2) == 0)
//       return false;
//   return true;
// }

// bool sortbysec(const pair<lld , lld > &a, const pair<lld , lld > &b) {
//   return (a.ss < b.ss);
// }

/*

// Do SMTH instead of sitting mofo

// BINARY SEARCH zarur dekh lena (kaafi useful)

// String ka question hai to y zarur dekh lena kahi Dsu ya Graph se solve ho jae

// CONSTRUCTIVE ALGOS ke case mai pattern ke alava brute force bhi karke dekh lena
// jese digits hai to ek extra 0 se 9 tk ka ya agar character hai to ek 'a' se 'z' tak
// for loop laga kar check karo ki kahi
// ek particular X mil jae jo pattern crack kar de....

// keep in mind apna best dena ki zarurat tabhi sabse zada hoti hai
// jab aap sabse zada kharab state mai ho tabhi kuch hoga

// BHAI  .... DP with recurrance contest 672 nuksaan ho gaya tha dp na soch kar

*/

// 12 : 38

lld rec(lld x) {

  if (x < 10)
    return x;

  if (x < 100) {
    return 18;
  }

  lld ans = 1;

  string temp = to_string(x);

  rep(i , 0 , temp.length() - 2) {

    ans *= 10;

  }

  ans *= 9;

  x =  pow(10 , temp.length() - 1) - 1;
  ans = ans + rec(x);

  return ans;
}

string s;

lld cal(lld x) {

  lld a = 1 , b = 1;
  rep(i , 1 , s.length() - 1) {
    int cur = s[i] - '0';
    a *= 9;
  }

  a *= (s[0] - 1 - '0');

  if (s[0] <= s.back()) {
    rep(i , 1 , s.length() - 1) {
      int cur = s[i] - '0';
      if (cur)
        b *= (cur + 1);
    }
  }

  else
    b = 0;

  return (a + b);

}

void sober() {
  lld n , x = 0 , a = 0 , b = 0 , y = 0 , sum = 0 , k = 0 , m = 0;
  cin >> n >> x;

  lld ans = 0 , ans1 = 0;

  // cout << pow(10 , max((lld)log10(x) , 1LL)) << "\n";

  ans = rec(pow(10 , max((lld)log10(x) , 1LL)) - 1) , ans1 = rec(pow(10 , max(1LL , (lld)log10(n))) - 1);
  s = to_string(x);

  // cout << ans << " " <<  ans1 << "\n";

  ans += cal(x) ;

  s = to_string(n) ;

  ans1 += cal(n - 1);

  if(x < 10){
    ans = x;
  }

  if(n < 10)
    ans1 = n - 1;

  // cout << ans << " " << ans1 << "\n";

  cout << ans - ans1 << "\n";

}

signed main() {

#ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin) ;
  freopen("output.txt" , "w" , stdout) ;
#endif

  DIEHOD;
  lld t = 1;
  // cin >> t;
  while (t--) {
    sober();
  }
}

//  c0ded by :
// - - - - - - - - - - - - - - - - - - - - - - s 0 b e r and s i m r a n


/*
 * Author    : raj1307 - Raj Singh
 * Date      : 01.02.2020
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;

//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cerr << *it << " "; cerr << endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}

#else
#define deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define debarr(a,n) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return
#define mp make_pair
#define pb push_back
#define sz(x) ((int)x.size())
#define int long long
typedef pair<int, int> ii;;
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}
int gcd(int a,int b){ return (b == 0) ? a : gcd(b, a % b);}
inline int lcm(int a,int b){ return a / gcd(a, b) * b;}
inline int normalize(int x,int mod){ x %= mod; if (x < 0) x += mod; return x;}

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
const int mod = 1000*1000*1000+7;
//const int mod = 998244353;
const int inf = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int N = 1e4 + 5;

int n,m;

int len;
int a[20];
int cache[20][10][2];

int dp(int i, int firstdig, int checksmall)
{
	if(i==len+1)
		return checksmall;
	if(i==len)
	{
		if(checksmall)
			return 1;
		if(firstdig<a[i])
			return 1;
		return 0;
	}
	int &ans=cache[i][firstdig][checksmall];
	if(ans!=-1)
		return ans;
	ans=0;
	if(checksmall)
	{
		for(int j=0;j<=9;j++)
		{
			ans+=dp(i+1, firstdig, 1);
		}
	}
	else
	{
		for(int j=0;j<=a[i];j++)
		{
			ans+=dp(i+1, firstdig, j<a[i]);
		}
	}
	return ans;
}

int f(int k)
{
	int storelen=0;
	int idx=1;
	while(k>0)
	{
		a[idx++]=k%10;
		k/=10;
		storelen++;
	}
	reverse(a+1, a+storelen+1);
	int ans=0;
	for(int l=1;l<=storelen;l++)
	{
		len=l;
		memset(cache, -1, sizeof(cache));
		for(int firstdig=1;firstdig<=9;firstdig++)
		{
			if(l<storelen || firstdig<=a[1])
				ans+=dp(2, firstdig, firstdig<a[1]||l<storelen);
		}
	}
	return ans;
}

void solve(){

	int l,r;
	cin>>l>>r;
	int ans=f(r+1) - f(l);
	cout<<ans;

}

signed main() {
	fio;
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	freopen("error.txt", "w", stderr);
	#endif
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;  // UNCOMMENT FOR TEST-CASES
//	precompute();
	while(t--) {
		solve();
	}

	return 0;
}


#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll inf = ~0ull >> 1;
int f(ll x) {
    while (x / 10) {
        x /= 10;
    }
    return x;
}
int w(ll x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}
ll cnt[20][10];
int main() {
    for (int i = 1; i <= 18; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (j == 1) {
                cnt[i][j] = cnt[i - 1][9] + (ll)pow(10, max(0, i - 2));
            }
            else
                cnt[i][j] = cnt[i][j - 1] + (ll)pow(10, max(0, i - 2));
            //cout << i << ' ' << j << ' ' << cnt[i][j] << endl;
        }
    }
    IO;
    ll l, r;
    cin >> l >> r;
    int lw = w(l), rw = w(r);
    int fl = f(l), fr = f(r);
    ll x = cnt[lw][fl - 1], y = cnt[rw][fr - 1];
    if (fl == 1)
        x = cnt[lw - 1][9];
    if (fr == 1)
        y = cnt[rw - 1][9];
    //cout << x << ' ' << y << endl;
    x += max(1ll, (l / 10 - fl * max(10ll, (ll)pow(10, lw - 2))) + 1);
    y += max(1ll, (r / 10 - fr * max(10ll, (ll)pow(10, rw - 2))) + 1);
    //cout << r / 10 - max(10ll, (ll)pow(10, rw - 2)) + 1 << endl;
    if (fl > l % 10)
        x--;
    if (fr > r % 10)
        y--;
    //cout << x << ' ' << y << endl;
    ll ans = y - x;
    if (fl == l % 10)
        ans++;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll inf = ~0ull >> 1;
int f(ll x) {
    while (x / 10) {
        x /= 10;
    }
    return x;
}
int w(ll x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}
ll cnt[20][10];
int main() {
    for (int i = 1; i <= 18; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (j == 1) {
                cnt[i][j] = cnt[i - 1][9] + (ll)pow(10, max(0, i - 2));
            }
            else
                cnt[i][j] = cnt[i][j - 1] + (ll)pow(10, max(0, i - 2));
            //cout << i << ' ' << j << ' ' << cnt[i][j] << endl;
        }
    }
    IO;
    ll l, r;
    cin >> l >> r;
    int lw = w(l), rw = w(r);
    int fl = f(l), fr = f(r);
    ll x = cnt[lw][fl - 1], y = cnt[rw][fr - 1];
    if (fl == 1)
        x = cnt[lw - 1][9];
    if (fr == 1)
        y = cnt[rw - 1][9];
    //cout << x << ' ' << y << endl;
    if (l % 10 >= fl) {
        x += max(1ll, (l / 10 - max(10ll, (ll)pow(10, lw - 2))) + 1);
    }
    if (r % 10 >= fr) {
        y += max(1ll, (r / 10 - max(10ll, (ll)pow(10, rw - 2))) + 1);
    }
    //cout << x << ' ' << y << endl;
    ll ans = y - x;
    if (fl == l % 10)
        ans++;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define M 1000000007
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define d(x) cout << #x << " " << x << "\n";
#define ll long long int
#define ul unsigned long long int
#define p pair<int, int>
using namespace std;

unsigned long long int power(unsigned long long int x, unsigned long long int i)
{
    unsigned long long int ans = 1;
    while (i)
    {
        if (i % 2 != 0)
        {
            ans = (ans * x);
        }
        i /= 2;
        x = (x * x);
    }
    return ans;
}

ll f(string s)
{
    if (s.size() == 1)
    {
        return s[0] - 48;
    }
    if (s.size() == 2)
    {
        return 9 + stoi(s) / 11;
    }
    ll sum = 18 + (10 * (power(10, s.size() - 3) - 1));
    ll x, y;
    for (int i = 1; i <= 9; i++)
    {
        if (i > s[0] - 48)
        {
            break;
        }
        y = 0;
        if (i > s.back() - 48)
        {
            y = 1;
        }
        if (i == s[0] - 48)
        {
            string p0;
            for (size_t j = 1; j < s.size() - 1; j++)
            {
                p0.push_back(s[j]);
            }
            stringstream no(p0);
            no >> x;
            sum += (x - y + 1);
        }
        else
        {
            x = 1;
            for (size_t j = 1; j < s.size() - 1; j++)
            {
                x *= 10;
            }
            sum += x;
        }
    }
    return sum;
}

int main()
{
    string l, r;
    cin >> l >> r;
    int x = 0;
    if (l.back() == l.front())
    {
        ++x;
    }
    cout << f(r) - f(l) + x;
}


#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
long double points[1000000][2]={{0}};
int num=0;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int nump(int ax,int ay,int bx, int by,double m0,int m1){
    if(m0==1e8){return abs(by-ay)+1;}
    if(m0==0){return abs(bx-ax)+1;}
    return (abs(bx-ax))/m1+1;
}

int intsec(int a1x,int a1y,int b1x,int b1y,int a2x,int a2y,int b2x,int b2y,long double m10,int m11,long double m20,int m21){
    long double y,x,temp;
    int check=0;
    if(m10==m20){
        check=0;
    }
    else if(m10!=1e8 && m20!=1e8){
        y=(a1y*m20-a2y*m10+m10*m20*(a2x-a1x))/(long double)(m20-m10);//cout<<y<<endl;
        if(abs(m10)>=1e-4){
            x=(long double)(y-a1y)/(double)m10+a1x;
        }
        else{
            x=(long double)(y-a2y)/(double)m20+a2x;
        }
        if((a1x-x)*(b1x-x)<=1e-2 && (a2x-x)*(b2x-x)<=1e-2 && (a1y-y)*(b1y-y)<=1e-2 && (a2y-y)*(b2y-y)<=1e-2 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m10==1e8 && m20!=1e8){
        x=(double)a1x;
        y=(double)a2y+m20*(x-a2x);
        if((a1x-x)*(b1x-x)<=1e-2 && (a2x-x)*(b2x-x)<=1e-2 && (a1y-y)*(b1y-y)<=1e-2 && (a2y-y)*(b2y-y)<=1e-2 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m20==1e8 && m10!=1e8){
        x=(double)a2x;
        y=(double)a1y+m10*(x-a1x);
        if((a1x-x)*(b1x-x)<=1e-2 && (a2x-x)*(b2x-x)<=1e-2 && (a1y-y)*(b1y-y)<=1e-2 && (a2y-y)*(b2y-y)<=1e-2  && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }return check;
}

long long int correct(long double points[][2], int num){
    long double temp[num][3]={{0}},correctness1=0,correctness2=0;
    int count=0,check=0,index=0;;
    for(int i=0; i<num; i++){
        for(int j=0; j<count; j++){
            if(points[i][0]<temp[j][0]+1e-8  && points[i][0]>temp[j][0]-(1e-8) && points[i][1]>temp[j][1]-(1e-8) && points[i][1]<temp[j][1]+1e-8){
                check=1;index=j;
            }
        }
        if(check==1){
            temp[index][2]++;
        }
        else{
           temp[count][0]=points[i][0];
           temp[count][1]=points[i][1];
           temp[count][2]++;count++;
        }
    }//cout<<temp[count-1][2]<<endl;
    for(int i=0; i<count; i++){
        if(temp[i][2]!=1){
            correctness1+=(sqrt(1+8*temp[i][2])-1)/2.;
            correctness2+=temp[i][2];
        }
    }
    return correctness2-correctness1;
}

int main() {
	int n;
	cin>>n;
	int a[n][2],b[n][2],c;long double m[n][2];
	for(int i=0; i<n; i++){
	    cin>>a[i][0]>>a[i][1]>>b[i][0]>>b[i][1];
	    if(b[i][0]!=a[i][0]){
	    m[i][0]=(double)(b[i][1]-a[i][1])/(double)(b[i][0]-a[i][0]);}
	    else{
	        m[i][0]=1e8;
	    }
	    m[i][1]=abs(b[i][0]-a[i][0])/gcd(abs(b[i][1]-a[i][1]),abs(b[i][0]-a[i][0]));
	}

	long long int sum=0,sub=0;
	for(int i=0; i<n; i++){
	    sum+=nump(a[i][0],a[i][1],b[i][0],b[i][1],m[i][0],m[i][1]);//cout<<a[i][0]<<" "<<a[i][1]<<" "<<b[i][0]<<" "<<b[i][1]<<" "<<m[i][0]<<" "<<m[i][1]<<" "<<sum<<endl;
	}
	for(int i=0; i<n; i++){
	    for(int j=i+1; j<n; j++){
	        sub+=intsec(a[i][0],a[i][1],b[i][0],b[i][1],a[j][0],a[j][1],b[j][0],b[j][1],m[i][0],m[i][1],m[j][0],m[j][1]);
	    }//cout<<sub<<endl;
	}
	c=correct(points,num);
//	cout<<sum<<" "<<sub<<" "<<c<<endl;
	cout<<sum-sub+c<<endl;

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
long long int points[1000000][2]={{0}};
int num=0;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int nump(int ax,int ay,int bx, int by,double m0,int m1){
    if(m0==1e8){return abs(by-ay)+1;}
    if(m0==0){return abs(bx-ax)+1;}
    return (abs(bx-ax))/m1+1;
}

int intsec(int a1x,int a1y,int b1x,int b1y,int a2x,int a2y,int b2x,int b2y,double m10,int m11,double m20,int m21){
    double y,x,temp;
    int check=0;
    if(m10==m20){
        check=0;
    }
    else if(m10!=1e8 && m20!=1e8){
        y=(a1y*m20-a2y*m10+m10*m20*(a2x-a1x))/(double)(m20-m10);//cout<<y<<endl;
        if(m10!=0){
            x=(double)(y-a1y)/(double)m10+a1x;
        }
        else{
            x=(double)(y-a2y)/(double)m20+a2x;
        }
        if((a1x-x)*(b1x-x)<=0 && (a2x-x)*(b2x-x)<=0 && (a1y-y)*(b1y-y)<=0 && (a2y-y)*(b2y-y)<=0 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m10==1e8 && m20!=1e8){
        x=(double)a1x;
        y=(double)a2y+m20*(x-a2x);
        if((a1x-x)*(b1x-x)<=0 && (a2x-x)*(b2x-x)<=0 && (a1y-y)*(b1y-y)<=0 && (a2y-y)*(b2y-y)<=0 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m20==1e8 && m10!=1e8){
        x=(double)a2x;
        y=(double)a1y+m10*(x-a1x);
        if((a1x-x)*(b1x-x)<=0 && (a2x-x)*(b2x-x)<=0 && (a1y-y)*(b1y-y)<=0 && (a2y-y)*(b2y-y)<=0  && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }return check;
}

long long int correct(long long int points[][2], int num){
    long long int temp[num][3]={{0}},correctness1=0,correctness2=0;
    int count=0,check=0,index=0;;
    for(int i=0; i<num; i++){
        for(int j=0; j<count; j++){
            if(points[i][0]==temp[j][0] && points[i][1]==temp[j][1]){
                check=1;index=j;
            }
        }
        if(check==1){
            temp[index][2]++;
        }
        else{
           temp[count][0]=points[i][0];
           temp[count][1]=points[i][1];
           temp[count][2]++;count++;
        }
    }
    for(int i=0; i<count; i++){
        if(temp[i][2]!=1){
            correctness1+=(sqrt(1+8*temp[i][2])-1)/2.;
            correctness2+=temp[i][2];
        }
    }
    return correctness2-correctness1;
}

int main() {
	int n;
	cin>>n;
	int a[n][2],b[n][2],c;long double m[n][2];
	for(int i=0; i<n; i++){
	    cin>>a[i][0]>>a[i][1]>>b[i][0]>>b[i][1];
	    if(b[i][0]!=a[i][0]){
	    m[i][0]=(double)(b[i][1]-a[i][1])/(double)(b[i][0]-a[i][0]);}
	    else{
	        m[i][0]=1e8;
	    }
	    m[i][1]=abs(b[i][0]-a[i][0])/gcd(abs(b[i][1]-a[i][1]),abs(b[i][0]-a[i][0]));
	}

	long long int sum=0,sub=0;
	for(int i=0; i<n; i++){
	    sum+=nump(a[i][0],a[i][1],b[i][0],b[i][1],m[i][0],m[i][1]);//cout<<a[i][0]<<" "<<a[i][1]<<" "<<b[i][0]<<" "<<b[i][1]<<" "<<m[i][0]<<" "<<m[i][1]<<" "<<sum<<endl;
	}
	for(int i=0; i<n; i++){
	    for(int j=i+1; j<n; j++){
	        sub+=intsec(a[i][0],a[i][1],b[i][0],b[i][1],a[j][0],a[j][1],b[j][0],b[j][1],m[i][0],m[i][1],m[j][0],m[j][1]);
	    }//cout<<sub<<endl;
	}
	c=correct(points,num);
//	cout<<sum<<" "<<sub<<" "<<c<<endl;
	cout<<sum-sub+c<<endl;

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
long double points[1000000][2]={{0}};
int num=0;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int nump(int ax,int ay,int bx, int by,double m0,int m1){
    if(m0==1e8){return abs(by-ay)+1;}
    if(m0==0){return abs(bx-ax)+1;}
    return (abs(bx-ax))/m1+1;
}

int intsec(int a1x,int a1y,int b1x,int b1y,int a2x,int a2y,int b2x,int b2y,long double m10,int m11,long double m20,int m21){
    long double y,x,temp;
    int check=0;
    if(m10==m20){
        check=0;
    }
    else if(m10!=1e8 && m20!=1e8){
        y=(a1y*m20-a2y*m10+m10*m20*(a2x-a1x))/(long double)(m20-m10);//cout<<y<<endl;
        if(abs(m10)>=1e-4){
            x=(long double)(y-a1y)/(double)m10+a1x;
        }
        else{
            x=(long double)(y-a2y)/(double)m20+a2x;
        }
        if((a1x-x)*(b1x-x)<=0 && (a2x-x)*(b2x-x)<=0 && (a1y-y)*(b1y-y)<=0 && (a2y-y)*(b2y-y)<=0 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m10==1e8 && m20!=1e8){
        x=(double)a1x;
        y=(double)a2y+m20*(x-a2x);
        if((a1x-x)*(b1x-x)<=0 && (a2x-x)*(b2x-x)<=0 && (a1y-y)*(b1y-y)<=0 && (a2y-y)*(b2y-y)<=0 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m20==1e8 && m10!=1e8){
        x=(double)a2x;
        y=(double)a1y+m10*(x-a1x);
        if((a1x-x)*(b1x-x)<=0 && (a2x-x)*(b2x-x)<=0 && (a1y-y)*(b1y-y)<=0 && (a2y-y)*(b2y-y)<=0  && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }return check;
}

long long int correct(long double points[][2], int num){
    long double temp[num][3]={{0}},correctness1=0,correctness2=0;
    int count=0,check=0,index=0;;
    for(int i=0; i<num; i++){
        for(int j=0; j<count; j++){
            if(points[i][0]<temp[j][0]+1e-8  && points[i][0]>temp[j][0]-(1e-8) && points[i][1]>temp[j][1]-(1e-8) && points[i][1]<temp[j][1]+1e-8){
                check=1;index=j;
            }
        }
        if(check==1){
            temp[index][2]++;
        }
        else{
           temp[count][0]=points[i][0];
           temp[count][1]=points[i][1];
           temp[count][2]++;count++;
        }
    }//cout<<temp[count-1][2]<<endl;
    for(int i=0; i<count; i++){
        if(temp[i][2]!=1){
            correctness1+=(sqrt(1+8*temp[i][2])-1)/2.;
            correctness2+=temp[i][2];
        }
    }
    return correctness2-correctness1;
}

int main() {
	int n;
	cin>>n;
	int a[n][2],b[n][2],c;long double m[n][2];
	for(int i=0; i<n; i++){
	    cin>>a[i][0]>>a[i][1]>>b[i][0]>>b[i][1];
	    if(b[i][0]!=a[i][0]){
	    m[i][0]=(double)(b[i][1]-a[i][1])/(double)(b[i][0]-a[i][0]);}
	    else{
	        m[i][0]=1e8;
	    }
	    m[i][1]=abs(b[i][0]-a[i][0])/gcd(abs(b[i][1]-a[i][1]),abs(b[i][0]-a[i][0]));
	}

	long long int sum=0,sub=0;
	for(int i=0; i<n; i++){
	    sum+=nump(a[i][0],a[i][1],b[i][0],b[i][1],m[i][0],m[i][1]);//cout<<a[i][0]<<" "<<a[i][1]<<" "<<b[i][0]<<" "<<b[i][1]<<" "<<m[i][0]<<" "<<m[i][1]<<" "<<sum<<endl;
	}
	for(int i=0; i<n; i++){
	    for(int j=i+1; j<n; j++){
	        sub+=intsec(a[i][0],a[i][1],b[i][0],b[i][1],a[j][0],a[j][1],b[j][0],b[j][1],m[i][0],m[i][1],m[j][0],m[j][1]);
	    }//cout<<sub<<endl;
	}
	c=correct(points,num);
//	cout<<sum<<" "<<sub<<" "<<c<<endl;
	cout<<sum-sub+c<<endl;

	return 0;
}


#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
long double points[1000000][2]={{0}};
int num=0;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int nump(int ax,int ay,int bx, int by,double m0,int m1){
    if(m0==1e8){return abs(by-ay)+1;}
    if(m0==0){return abs(bx-ax)+1;}
    return (abs(bx-ax))/m1+1;
}

int intsec(int a1x,int a1y,int b1x,int b1y,int a2x,int a2y,int b2x,int b2y,long double m10,int m11,long double m20,int m21){
    long double y,x,temp;
    int check=0;
    if(m10==m20){
        check=0;
    }
    else if(m10!=1e8 && m20!=1e8){
        y=(a1y*m20-a2y*m10+m10*m20*(a2x-a1x))/(long double)(m20-m10);//cout<<y<<endl;
        if(abs(m10)>=1e-4){
            x=(long double)(y-a1y)/(double)m10+a1x;
        }
        else{
            x=(long double)(y-a2y)/(double)m20+a2x;
        }
        if((a1x-x)*(b1x-x)<=1e-4 && (a2x-x)*(b2x-x)<=1e-4 && (a1y-y)*(b1y-y)<=1e-4 && (a2y-y)*(b2y-y)<=1e-4 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m10==1e8 && m20!=1e8){
        x=(double)a1x;
        y=(double)a2y+m20*(x-a2x);
        if((a1x-x)*(b1x-x)<=1e-4 && (a2x-x)*(b2x-x)<=1e-4 && (a1y-y)*(b1y-y)<=1e-4 && (a2y-y)*(b2y-y)<=1e-4 && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }
    else if(m20==1e8 && m10!=1e8){
        x=(double)a2x;
        y=(double)a1y+m10*(x-a1x);
        if((a1x-x)*(b1x-x)<=1e-4 && (a2x-x)*(b2x-x)<=1e-4 && (a1y-y)*(b1y-y)<=1e-4 && (a2y-y)*(b2y-y)<=1e-4  && abs(x-(int)x)<=1e-3 && abs(y-(int)y)<=1e-3){
            check=1;points[num][0]=x;points[num][1]=y;num++;
        }
    }return check;
}

long long int correct(long double points[][2], int num){
    long double temp[num][3]={{0}},correctness1=0,correctness2=0;
    int count=0,check=0,index=0;;
    for(int i=0; i<num; i++){
        for(int j=0; j<count; j++){
            if(points[i][0]<temp[j][0]+1e-8  && points[i][0]>temp[j][0]-(1e-8) && points[i][1]>temp[j][1]-(1e-8) && points[i][1]<temp[j][1]+1e-8){
                check=1;index=j;
            }
        }
        if(check==1){
            temp[index][2]++;
        }
        else{
           temp[count][0]=points[i][0];
           temp[count][1]=points[i][1];
           temp[count][2]++;count++;
        }
    }//cout<<temp[count-1][2]<<endl;
    for(int i=0; i<count; i++){
        if(temp[i][2]!=1){
            correctness1+=(sqrt(1+8*temp[i][2])-1)/2.;
            correctness2+=temp[i][2];
        }
    }
    return correctness2-correctness1;
}

int main() {
	int n;
	cin>>n;
	int a[n][2],b[n][2],c;long double m[n][2];
	for(int i=0; i<n; i++){
	    cin>>a[i][0]>>a[i][1]>>b[i][0]>>b[i][1];
	    if(b[i][0]!=a[i][0]){
	    m[i][0]=(double)(b[i][1]-a[i][1])/(double)(b[i][0]-a[i][0]);}
	    else{
	        m[i][0]=1e8;
	    }
	    m[i][1]=abs(b[i][0]-a[i][0])/gcd(abs(b[i][1]-a[i][1]),abs(b[i][0]-a[i][0]));
	}

	long long int sum=0,sub=0;
	for(int i=0; i<n; i++){
	    sum+=nump(a[i][0],a[i][1],b[i][0],b[i][1],m[i][0],m[i][1]);//cout<<a[i][0]<<" "<<a[i][1]<<" "<<b[i][0]<<" "<<b[i][1]<<" "<<m[i][0]<<" "<<m[i][1]<<" "<<sum<<endl;
	}
	for(int i=0; i<n; i++){
	    for(int j=i+1; j<n; j++){
	        sub+=intsec(a[i][0],a[i][1],b[i][0],b[i][1],a[j][0],a[j][1],b[j][0],b[j][1],m[i][0],m[i][1],m[j][0],m[j][1]);
	    }//cout<<sub<<endl;
	}
	c=correct(points,num);
//	cout<<sum<<" "<<sub<<" "<<c<<endl;
	cout<<sum-sub+c<<endl;

	return 0;
}