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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0

int main()
{
    vector<unsigned long long> potyczki;

    unsigned long long ten_eighteen = (unsigned long long)1000*1000*1000*1000*1000*1000;
    unsigned long long ten_six = (unsigned long long )1000*1000;

    for (unsigned long long i = 1; i <= ten_six + 10; ++i)
    {
        unsigned long long now = i;

        bool wrong = 0;
        unsigned long long new_num_tmp = now;
        while(new_num_tmp > 0)
        {
            unsigned long long this_num = (unsigned long long )new_num_tmp%10;
            
            if (this_num == 0 || now % this_num != 0)
            {
                wrong = 1;
                break;
            }

            new_num_tmp /= 10;
        }

        if (wrong == 0)
        {
            potyczki.push_back(now);
            
        }
    
    }

#if DEBUG
    cout<<potyczki.size()<<" Potyczkovs found."<<endl;
    for (auto&& e:potyczki)
    {
        cout<<"\t"<<e<<endl;
    }
    cout<<endl;
#endif

    unsigned long long lo, hi;
    cin>>lo>>hi;
    unsigned res = 0;

    for (auto&& e : potyczki)
    {
        if (e >= lo && e <= hi)
        {
            ++res;
        }
    }

    cout<<res<<endl;

    return 0;
}