#include using namespace std; #define rep(i,n) for (int i = 0; i < n; ++i) using ll = long long; using P = pair; int K,N; struct Sieve { int n; vector f, primes; Sieve(int n=1):n(n), f(n+1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; if(i>=K)primes.push_back(i); f[i] = i; for (ll j = i*i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x;} vector factorList(int x) { vector res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector

factor(int x) { vector fl = factorList(x); if (fl.size() == 0) return {}; vector

res(1, P(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } }; int h(int x){ if(x<10)return x; int y=0; while(x!=0){ y+=x%10; x/=10; } return h(y); } bool check[10]; int main() { cin>>K>>N; Sieve prime(N); int l=0,r=0,ans,Max=0; vectorP=prime.primes; rep(i,P.size()){ P[i]=h(P[i]); } while(r