#include <cstdio>#include <iostream>#include <cstring>
using namespace std;
#define LL long long
LL a[20], dp[20][180][180];
LL dfs( intpos, int p, int sta1, int sta2, int flg ){
if ( pos == -1 ) return (sta1 == 0 && sta2 == p );
if ( sta2 > p || sta2 + (pos+1)*9 < p ) return0;
if ( !flg && dp[pos][sta1][sta2] != -1 ) return dp[pos][sta1][sta2];
int up = flg ? a[pos] : 9;
LL ret = 0;
for ( int i = 0; i <= up; i++) ret += dfs( pos-1, p, (sta1*10+i)%p, sta2 + i, flg && ( i == up ) );
if ( !flg ) dp[pos][sta1][sta2] = ret;
return ret;
}
LL solve( LL x ){
intpos = 0;
for( ; x; a[pos++] = x % 10, x /= 10);
if( !pos ) return 0ll;
LL ans = 0;
for ( int i = 1; i <= pos*9; i++){
memset( dp, -1, sizeof(dp));
ans += dfs( pos-1, i, 0, 0, 1);
}
return ans;
}
int main(){
LL l, r;
cin>>l>>r;
cout<<solve(r)-solve(l-1)<<endl;
}