import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long[] allThrees = new long[63]; allThrees[0] = 3; for (int i = 1; i < 63; i++) { allThrees[i] = allThrees[i - 1] * (1 + pow(10, 1L << (i - 1))) % MOD; } long ans = 0; int add = 0; long x = n; for (int i = 0; i < 63 && x > 0; i++) { if (x % 2 == 1) { ans *= pow(10, 1L << i); ans %= MOD; ans += allThrees[i]; ans %= MOD; add += i + 1; } x /= 2; } ans += pow(10, n); ans %= MOD; System.out.println(ans); } static long pow(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } }