#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  const int MOD = 1000000007;
  cin >> n;
  long long int b[30] = {1, 2};
  for (int i = 2; i < 20; i++) {
    b[i] = 1;
    for (int j = 0; j < 10; j++) b[i] = (b[i] * b[i - 1]) % MOD;
  }
  long long int x = 1;
  int cnt = 1;
  while (n) {
    int t = n % 10;
    n /= 10;
    for (int i = 0; i < t; i++) x = (x * b[cnt]) % MOD;
    cnt++;
  }
  long long int y = x;
  x = ((x * x - x) / 2) % MOD;
  cout << (x + y) % MOD << '\n';
  return 0;
}
