1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
using namespace std;

bool ok(long long x)
{
	long long y=x;
	
	while (x)
	{
		long long d = x%10;
		if (d==0 || !(y%d == 0)) return false;
		x/=10;
	}
	
	return true;
}


long long next(long long i)
{
	i++;
	long long j=i;
	long long jed=0;
	while (i%10==0)
	{
		jed*=10;
		jed+=1;
		i/=10;
	}
	return j+jed;
}

int main() {
	// your code goes here
	long long l,r,c=0;
	scanf("%lld %lld",&l,&r);
	for (long long i=l;i<=r;i=next(i))
	{
		if (ok(i)) 
		{
			//printf("%lld, ",i);
			c++;
		}
		//printf("%lld\n",i);
		
	}
	printf("%lld\n",c);
	return 0;
}