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

bool potyczkov_number(long long n) {
    long long aggr = n;
    while (aggr > 0) {
        if (aggr % 10 == 0) return false;
        if (n % (aggr % 10) != 0) return false;
        aggr = aggr / 10;
    }
    return true;
}

int main() {
    long long l, r;
    std::cin >> l >> r;
    long long count = 0;
    for (;l <= r; ++l) {
        if (potyczkov_number(l)) {
//            std::cout << l << ' ';
            ++count;
        }
//        if (l % 100 == 0) std::cout << '\n';
    }
//    std::cout << '\n';
    std::cout << count << '\n';
    return 0;
}