#include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #define debug(x) cerr << #x << " = " << (x) << endl; #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 100010 int main(){ ll n; set mm; scanf("%lld",&n); int m = n/1000000000; int ans = 0; for(int i=0;i<=m;i++){ int p = i; char s1[20],s1_r[20],s2[20]; sprintf(s1_r,"%d",p); reverse(s1_r,s1_r+strlen(s1_r)); sprintf(s1,"%d%s",p,s1_r); sprintf(s2,"%d%s",p/10,s1_r); ll q1 = atoll(s1); ll q2 = atoll(s2); //debug(q1); //debug(q2); if(q1 < 1000000000LL && q1 + q1*1000000000 <= n && mm.find(q1) == mm.end()){ mm.insert(q1); ans++; } if(q2 < 1000000000LL && q2 + q2*1000000000 <= n && mm.find(q2) == mm.end()){ mm.insert(q2); ans++; } if(q1 >= 10000000000LL) break; } cout << ans-1 << endl; return 0; }