ref
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
int a[15];
ll u, v, dp[11][11][11][2][2][2][2];
//[算当前剩几位][当前最大可用][上一位是啥][是否slj][上一位是否=上上一位][有无4][有无8]
ll f(int now, int lim, int lst, bool slj, bool ise, bool is4, bool is8){
ll &re=dp[now][lim][lst][slj][ise][is4][is8];
if(re>=0) return re;
re = 0;
if(now==1)
for(int i=0; i<=min(9, lim); i++){
if((is4 && i==8) || (is8 && i==4)) continue;
re += slj || (ise && i==lst);
}
else
for(int i=0; i<=min(9, lim); i++){
if((is4 && i==8) || (is8 && i==4)) continue;
re += f(now-1, (i<lim||lim==10)?10:a[now-1], i, slj||(ise&&i==lst), i==lst, is4||i==4, is8||i==8);
}
return re;
}
ll calc(ll x){
if(x<1e10) return 0;
memset(dp, -1, sizeof(dp));
ll re=0;
for(int i=1; i<=11; i++){
a[i] = x % 10;
x /= 10;
}
for(int i=1; i<=a[11]; i++)
re += f(10, i==a[11]?a[10]:10, i, 0, 0, i==4, i==8);
return re;
}
int main(){
cin>>u>>v;
cout<<calc(v)-calc(u-1)<<endl;
return 0;
}