#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) templatebool chmin(T&a,const T&b){return a>b?(a=b,true):false;} templatebool chmax(T&a,const T&b){return a 0) { if (b & 1) res = (res * a) % p; a = (a * a) % p; b >>= 1; } return res; } ll f(int N, ll MOD) { return 9 * mod_pow(10, (N-1)/2, MOD) % MOD; } const int MAX_N = 100000 + 10; ll dp[MAX_N][2]; ll solve(vector a, ll MOD) { memset(dp, 0, sizeof(dp)); int N = (int)a.size(); dp[0][0] = 1; for (int i = 0; i < (N+1)/2; i++) { for (int k = 0; k < 2; k++) { for (int d = (i==0?1:0); d <= 9; d++) { if (k == 1 || d < a[i]) { (dp[i+1][1] += dp[i][k]) %= MOD; } else if (k == 0 && a[i] == d) { (dp[i+1][0] += dp[i][k]) %= MOD; } } } } // REP(i, N+1) { // cout << dp[i][0] << " " << dp[i][1] << endl; // } ll res = 0; res += dp[(N+1)/2][1]; bool is = true; REP(i, N/2) if (a[i] > a[N-1-i]) is = false; if (is) { res = (res + 1) % MOD; } // 桁数がN未満の回文数 for (int i = 1; i < N; i++) { res += f(i, MOD) % MOD; res %= MOD; } return res % MOD; } bool isok(int x) { stringstream ss; ss << x; string s = ss.str(); for (int i = 0; i < (int)s.size()/2; i++) { if (s[i] != s[s.size() - 1 - i]) return false; } return true; } ll solveSmall(const vector a, ll MOD) { int N = (int)a.size(); if (N >= 6) return -1; int n = 0; REP(i, N) { n = n * 10 + a[i]; } ll res = 0; for (int x = 1; x <= n; x++) { if (isok(x)) ++res; } return res; } int main2() { string s; cin >> s; vector a(s.size()); REP(i, s.size()) a[i] = s[i] - '0'; cout << solve(a, (ll)1e9) << endl; cout << solve(a, (ll)1e9+7) << endl; // cout << solveSmall(a, (ll)1e9) << endl; // cout << solveSmall(a, (ll)1e9+7) << endl; return 0; } int main() { for (;!cin.eof();cin>>ws) main2(); return 0; }