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
#include <cstdio>

bool czyLiczbaPotyczkowa(long long int liczba) {
	long long int badanaLiczba = liczba;

	while (liczba > 0) {
		long long int cyfra = liczba % 10;
		if (cyfra == 0) {
			return false;
		}

		if (badanaLiczba % cyfra != 0) {
			return false;
		}
		liczba /= 10;
	}

	return true;
}

int main() {
	long long int l, r;
	scanf("%lld %lld", &l, &r);

	long long int result = 0;
	for (long long int i = l; i <= r; i++) {
		if (czyLiczbaPotyczkowa(i)) {
			result++;
		}
	}

	printf("%lld", result);

	return 0;
}