#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef pair P; typedef pair PL; ll powll(ll x, ll y){ if (y == 0) return 1; return x * powll(x, y-1); } int main() { ll n; cin >> n; int ans = 0; FOR(i,1,9){ int lim = powll(10,(i+1)/2); FOR(p,1,lim-1){ if (p % 10 == 0) continue; ll x = p, y = p; REP(a,i/2){ x += (y%10)*powll(10,i-a-1); y /= 10; } // cout << x << endl; x += x*powll(10,9); // cout << x<< endl; if (x <= n){ ans++; } } } cout << ans << endl; return 0; }