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 <bits/stdc++.h>
#define ll long long
#define sz(x) (int)x.size()

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll l, r;
    cin >> l >> r;
    ll ans = 0;
    for(ll i = l; i <= r; i++) {
        ll act = i;
        vector<ll> digs;
        while(act > 0) {
            digs.push_back(act % 10);
            act /= 10;
        }
        bool pot = 1;
        for(ll d : digs) if(d == 0 || i % d != 0) pot = 0;
        if(pot) {
            ans++;
        }
    }
    cout << ans << '\n';
}