#include using namespace std; using int64 = long long; const int64 mod = 1e9 + 7; using pi = pair< int, int >; int64 power(int64 x, int64 n) { int64 ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= mod; (x *= x) %= mod; n >>= 1; } return ret; } int64 rec(int64 length, int64 weight, bool l) { if(length == 1) return l ? weight : 3 * weight % mod; int64 mid = length >> 1; int64 ret = 0; (ret += rec(mid, weight, false)) %= mod; (ret += rec(length - mid, weight * power(10, mid) % mod, l)) %= mod; return ret; } int main() { int64 N; cin >> N; assert(1LL <= N && N <= 1000000000000000000LL); cout << rec(N + 1, 1, true) << endl; }