#include #define rep(i,a,b) for(int i=a;i= mod ? x - mod : x; } template int add(int mod, int x, T... y) { return add(mod, x, add(mod, y...)); } int mul(int mod, int x, int y) { return 1LL * x * y % mod; } template int mul(int mod, int x, T... y) { return mul(mod, x, mul(mod, y...)); } int sub(int mod, int x, int y) { return add(mod, x, mod - y); } int modpow(int mod, int a, long long b) { int ret = 1; while (b > 0) { if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; } int modinv(int mod, int a) { return modpow(mod, a, mod - 2); } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ string N; int n; //--------------------------------------------------------------------------------------------------- int to_integer(string s, int mod) { int res = 0; rep(i, 0, s.length()) { int c = s[i] - '0'; res = (1LL * res * 10 + c) % mod; } return res; } //--------------------------------------------------------------------------------------------------- int count(int mod) { int len = (n + 1) / 2; string pre = N.substr(0, len); int ma = to_integer(pre, mod); string line = "1"; rep(i, 0, len - 1) line += "0"; int mi = to_integer(line, mod); return (ma - mi + mod) % mod; } //--------------------------------------------------------------------------------------------------- int solve(int mod) { n = N.length(); int ans = 0; // 1 rep(len, 1, n) { int res = 9; if (len == 1) { ans = res; continue; } res = mul(mod, res, modpow(mod, 10, (len - 1) / 2)); ans = add(mod, ans, res); } // 2-1 ans = add(mod, ans, count(mod)); // 2-2 if (n % 2 == 0) { bool ok = true; rep(i, 0, n / 2) { if (N[n / 2 - 1 - i] > N[i + n / 2]) ok = false; if (N[n / 2 - 1 - i] < N[i + n / 2]) break; } if (ok) ans = add(mod, ans, 1); } else { bool ok = true; rep(i, 0, n / 2) { if (N[n / 2 - 1 - i] > N[i + n / 2 + 1]) ok = false; if (N[n / 2 - 1 - i] < N[i + n / 2 + 1]) break; } if (ok) ans = add(mod, ans, 1); } return ans; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; cout << solve(1000000000) << endl; cout << solve(1000000007) << endl; }