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
// Karol Kosinski 2020
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORL(i,a,b) for(LL i=(a);i<=(b);++i)
using namespace std;

typedef long long LL;

LL solve_brut(LL a, LL b)
{
    LL res = 0;
    bool C[10];
    FORL(x,a,b)
    {
        FOR(i,0,10) C[i] = false;
        auto y = x;
        while (y > 0) {
            C[y % 10] = true;
            y /= 10;
        }
        if (C[0]) continue;
        FOR(i,2,10) if (C[i] and x % i != 0) goto endloop;
        ++res;
        endloop:;
    }
    return res;
}

int main()
{
    LL a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", solve_brut(a, b));
    return 0;
}