#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
ll L,R,f[30][20][20][2][2][2];
int a[30],len,cnt;
ll dfs(int pos,bool limit,bool eight,bool four,bool same,int last,int pre_last)
{
if(eight&&four) return 0;
if(!pos&&!eight&&!four) return 0;
if(!pos&&same) return 1;
if(!pos&&!same) return 0;
if(!limit&&pos<=9&&~f[pos][last][pre_last][same][eight][four])
{
return f[pos][last][pre_last][same][eight][four];
}
int up=limit?a[pos]:9;
ll res=0;
for(int i=(pos==11);i<=up;i++)
res+=dfs(pos-1,limit&&i==up,eight||i==8,four||i==4,same||(i==last&&last==pre_last),i,last);
if(!limit&&pos<=9)
f[pos][last][pre_last][same][eight][four]=res;
return res;
}
ll solve(ll x)
{
len=0;
while(x)
{
a[++len]=x%10;
x/=10;
}
return dfs(len,true,false,false,false,10,11);
}
int main()
{
memset(f,-1,sizeof(f));
scanf("%lld%lld",&L,&R);
printf("%lld\n",solve(R)-solve(L-1));
return 0;
}