#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>s; { string t(s); t.erase(unique(t.begin(),t.end()),t.end()); if(t.size()==1){ cout< cnt(10,0); for(char c:s) cnt[c-'0']++; Int ans=-1; for(Int i=0;i<10;i++){ for(Int j=0;j<10;j++){ if(!cnt[i]||!cnt[j]) continue; Int k=abs(i-j)*9; if(ans<0) ans=k; ans=__gcd(ans,k); } } Int res=0; for(char c:s){ res=res*10+(c-'0'); res%=ans; } cout<<__gcd(res,ans)<