#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<queue>
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
#define mmt(a,b) memset(a,b,sizeof(a))
#define pb push_back
#define mp make_pair
#define y1 fuck
#define N 200010
using namespace std;
typedef long long LL;
typedef long double LD;
int A,B;
int dp[11][11][11],sum[11][11];
void DP(int Len,bool st)
{
  int I,i,j,k;mmt(dp,0);mmt(sum,0);
  FOR(I,st,9) dp[I][1][I]=1;
  FOR(I,st,9) FOR(i,2,Len) FOR(j,0,9) FOR(k,0,9)
   if (abs(j-k)>=2) dp[I][i][k]+=dp[I][i-1][j];
  FOR(I,st,9) FOR(j,1,Len) FOR(k,0,9) sum[I][j]+=dp[I][j][k];
}
int solve(int x)
{
  if (x==0) return 0;int ct,i,j,k,st,ed;LL px;
  for(px=1,ct=0;px<=x;px*=10,ct++);px/=10;
  int tx=x,ans=0;
  DP(ct,1);
  ROF(i,ct-1,1)
  {
    FOR(j,1,9) ans+=sum[j][i];
  }
  DP(ct,0);
  int pre=-1;
  ROF(i,ct,1)
  {
    int j=tx/px;
    st=(i==ct?1:0);
    ed=(i==1?j:j-1);
    FOR(k,st,ed) 
     if (pre==-1||abs(k-pre)>=2)
     {
       ans+=sum[k][i];
     }
    if (pre!=-1&&abs(j-pre)<2) break;
    pre=j;tx%=px;px/=10;
  }
  return ans;
}
int main()
{
  scanf("%d%d",&A,&B);
  printf("%d\n",solve(B)-solve(A-1));
  return 0;
}