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
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>

typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

#define all(x) (x).begin(),(x).end()
#define debug std::cout<<"ok"<<std::endl

const ll INF=1e18;
const ll SMALLINF=1e8;

bool check (ll k)
{
    ll t=k;
    if (!t)
        return false;
    while(t)
    {
        if (!(t%10))
            return false;
        if (k%(t%10))
            return false;
        t=t/10;
    }
    return true;
} 

main ()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);

    int Z=1;
    //std::cin>>Z;
    while(Z--)
    {
        std::vector<ll> V;
        for (ll i=1; i<SMALLINF; i++)
            if (check(i))
                V.push_back(i);
        ll a,b;
        std::cin>>a>>b;
        std::cout<<std::lower_bound(all(V), b)-std::lower_bound(all(V), a)<<std::endl;
    }
}