#include #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); #define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2); template T pow(T x, long n) { T res = 1; T p = x; while( n != 0 ) { if( n & 0x01 ) res *= p; p *= p; n >>= 1; } return res; } // void greedy(long x) { // long t = 1000000001; // for(long i = t; i <= x; i+=t) { // if( // } // } long f(std::string str, int b, int n) { if( n == 0 ) return 0; if( n == 1 ) return str[b] - '0' + (b == 0 ? 0 : 1); long res = pow(10, n - 1) * std::max(0, str[b] - '0' - (b == 0 ? 1 : -1)) + f(str, b + 1, n - 1); dumpl(res); return res; } int main() { long dp[32] = {}; // dp[1] = 9; // dp[2] = 9; // dp[3] = 9 * 10; // dp[4] = 9 * 10; // dp[5] = 9 * 10 * 10; for(int i = 0; i < 32; ++i) { dp[i] = 9 * pow(10, (i-1)/2); } std::string str; std::cin >> str; long t = std::stol(str); if( t < 1000000001 ) { puts("0"); return 0; } long low = t % 1000000000; long high = t / 1000000000; long m = (int)str.size() - 9; long x = f(str, 0, (m + 1) / 2); dumpl(m); // long x = 0; for(int i = 1; i < m; ++i) { x += dp[i]; } // for(int i = 1; i < m; ++i) { // x += dp[i]; // } // x += (str[0] - '0') * pow(10, std::max((long)0, (m - 1)/2)); long res = x; if( high > low ) res = std::max(long(0), res - 1); printf("%ld\n", res); return 0; }