K=int(raw_input()) N=int(raw_input()) isPrime=[True for i in range(N+1)] isPrime[0]=False isPrime[1]=False primes=[] for i in range(N+1): if isPrime[i]: for j in range(i+i,N+1,i): isPrime[j]=False if i>=K and i <=N: primes.append(i) hashs=[] for p in primes: while p>=10: q = 0 while p!=0: q+=p%10 p/=10 p=q hashs.append(p) maxLen=0 ans = 2 for i in range(len(primes)): isUsed=[False for k in range(10)] curLen=0 j = i while j