#include using namespace std; typedef long long int64; string S; int64 dp[100001][2][2]; int64 dp2[100001]; int64 rec2(int idx, const int mod) { if(idx <= 0) return (1); if(idx % 2 == 1) return (rec2(idx - 1, mod) * 10 % mod); if(~dp2[idx]) return (dp2[idx]); return (dp2[idx] = rec2(idx - 2, mod) * 10 % mod); } int64 rec(int idx, bool free, bool less, const int mod) { if(~dp[idx][free][less]) return (dp[idx][free][less]); if(S.size() / 2 == idx) { if(less && !free) { if(S.size() % 2 == 0) return (0); else return (1); if(S[idx] == '0') return (0); return (S[idx] - '0'); } if(S.size() % 2 == 1) return (free ? 10 : S[idx] - '0' + 1); else return (1); } int64 ret = 0; int end = free ? 9 : S[idx] - '0'; for(int i = 0; i <= end; i++) { if(idx == 0 && i == 0) continue; bool nt = free | (i != end); if(!nt && S[S.size() - idx - 1] - '0' < i) { (ret += rec(idx + 1, free | (i != end), true, mod)) %= mod; } else { (ret += rec(idx + 1, free | (i != end), less, mod)) %= mod; } } return (dp[idx][free][less] = ret); } int64 ct(int mod) { memset(dp, -1, sizeof(dp)); memset(dp2, -1, sizeof(dp2)); int64 ret = 0; for(int i = 0; i < S.size() - 1; i++) { ret += rec2(i - 1, mod) * 9; ret %= mod; } return ((ret + rec(0, 0, 0, mod)) % mod); } int main() { cin >> S; if(S.size() == 1) { cout << S << endl << S << endl; return (0); } cout << ct(1e9) << endl; cout << ct(1e9 + 7) << endl; }