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
#include <iostream>
#include <string>

using namespace std;

bool test(long long n) {
	long long x = n;
	bool tab[10] = {0};

	while (x > 0) {
		tab[x % 10] = true;
		if (tab[0])
			return false;
		x /= 10;
	}

	for (int i = 2; i < 10; ++i) {
		if (tab[i]) {
			if (n % i != 0)
				return false;
		}
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);

	long long l,r;
	long long count = 0;
	cin>>l>>r;

	for (; l <= r; ++l) {
		if (test(l))
			++count;
	}

	cout<<count<<"\n";
	return 0;
}