#include using namespace std; #define rep(i,a,b) for(int i=a;i=b;i--) typedef long long ll; ll N; //----------------------------------------------------------------- int main() { cin >> N; int ans = 0; rep(i, 1, 101010) { string s = to_string(i); int n = s.length(); bool ng = false; rep(j, 0, n) if (s[j] == '0') ng = true; if (ng) continue; // 奇数 ll x = 0; rep(i, 0, n - 1) x = x * 10 + s[i] - '0'; x = x * 10 + s[n - 1] - '0'; rep(i, 0, n - 1) x = x * 10 + s[n - 2 - i] - '0'; //cout << x << endl; int nx = (n - 1) * 2 + 1; ll a = x; rep(i, 0, 9) a *= 10; a += x; if (a < 0) continue; if (a <= N) { //printf("%lld\n", a); ans++; } // 偶数 ll xx = 0; rep(i, 0, n) xx = xx * 10 + s[i] - '0'; rep(i, 0, n) xx = xx * 10 + s[n - 1 - i] - '0'; //cout << xx << endl; int nxx = n * 2; ll b = xx; rep(i, 0, 9) b *= 10; b += xx; if (b < 0) continue; if (b <= N) { //printf("%lld\n", b); ans++; } } cout << ans << endl; /* ll mo = 1000000001; int dig = 0; ll t = N; while (0 < t) dig++, t /= 10; ll ans = 0; rrep(i, 8, 1) { ll cc = 0; int d = i + 2 * (9 - i); if (d < dig) { // 全部OK int j = 9 - i; if (j == 1) { cc = 9; } else if (j % 2 == 0) { int k = j / 2 - 1; ll c = 9; rep(kk, 0, k) c *= 9; cc += c; } else { int k = j / 2; ll c = 9; rep(kk, 0, k) c *= 9; cc += c; } } else if (d == dig) { // 一部OK int j = 9 - i; string n = to_string(N); int ma = 0; rep(i, 0, j) ma = ma * 10 + n[i] - '0'; int mi = 0; rep(i, 0, j) mi = mi * 10 + 1; if (mi < ma) { //if(j % 2 == 0) rep(x, mi, ma) { string s = to_string(x); bool ok = true; rep(i, 0, s.length() / 2 + 1) { int j = s.length() - 1 - i; if (s[i] != s[j]) ok = false; if (s[i] == '0') ok = false; } if (ok) cc++; } } ll th = ma; rep(i, 0, d - j * 2) th *= 10; int y = ma; while (0 < y) { th = th * 10 + y % 10; y /= 10; } if (th <= N) cc++; //cout << th << endl; //printf("[%d %d]\n", mi, ma); } ans += cc; //if(0 < cc) printf("%d -> %lld\n", d, cc); } cout << ans << endl;*/ }