#include "bits/stdc++.h" using namespace std; const int N=200010; int a,b,c,p[N],h[N],is_p[N],l,ans,vis[20]; int h0(int n) { while (n>=10) { int m=0; while (n) m+=n%10,n/=10; n=m; } return n; } int main() { memset(is_p,0x3f,sizeof(is_p)); is_p[0]=is_p[1]=0; for (int i=2;i*i>a>>b; for (int i=a;i<=b;++i) if (is_p[i]) ++c,p[c]=i,h[c]=h0(i); assert(c>=1); for (int i=1,j=2;i<=c;++i) { vis[h[i]]=1; // if (i==j) ++j; while (j<=c) { if (vis[h[j]]) break; vis[h[j]]=1; ++j; } if (l<=j-i) l=j-i,ans=p[i]; // if (j>b) break; vis[h[i]]=0; } cout<