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
#include <iostream>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    long long l, r;
    cin >> l >> r;
    long long found = 0;
    for(int i=l; i<=r; i++) {
        int x = i;
        bool stop = false;
        while (x > 0 && !stop) {
            int r = x % 10;
            if (r == 0 || i % r != 0) {
                stop = true;
                break;
            }
            x /= 10; 
        }
        if (!stop) {
            found++;
        }
    }
    cout << found << endl;
    return 0;
}