#include using namespace std; #define fi first #define se second #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define each(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define mp(a,b) make_pair(a,b) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<(x).count() typedef long long ll; typedef unsigned long long ull; typedef pair P; typedef pair PPI; typedef pair PL; typedef pair PPL; #define INF INT_MAX/3 #define MAX_N 1000 bool isp(string s){ int n=s.length(); rep(i,n/2)if(s[i]!=s[n-i])return false; return true; } ll rec(string n,ll nd,ll digit,bool flag){ if(nd>digit/2+digit%2)return flag||isp(n); if(flag)return 10*rec(n,nd+1,digit,flag); ll res=0; ll maxd=n[nd-1]-'0'; for(ll i=0;i<=maxd;i++){ if(nd==1&&i==0)continue; res+=rec(n,nd+1,digit,i>n; n/=1000000001; ll digit=1; for(ll x=1;x<=n;x*=10){ res+=rec(to_string(min(x*10-1,n)),1LL,digit++,false); } cout<