#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 solve(int mod) { int n = N.length(); int ans = 0; 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); } rep(i, 0, n / 2) { int c = N[i] - '0'; if (i == 0) { if (1 < c) ans = add(mod, ans, mul(mod, c - 1, modpow(mod, 10, n / 2 - i - 1))); } else { if (0 < c) ans = add(mod, ans, mul(mod, c, modpow(mod, 10, n / 2 - i - 1))); } } 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 { int c = N[n / 2] - '0'; ans = add(mod, ans, c); 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); if (n == 1) ans = sub(mod, ans, 1); } return ans; } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; cout << solve(1000000000) << endl; cout << solve(1000000007) << endl; }