#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
struct matrix {
  int f[3][3];
} ans, trans;
inline int ksm(long long b, int t) {
  static long long tmp;
  for (tmp = 1; t; b = b * b % mod, t >>= 1)
    if (t & 1) tmp = tmp * b % mod;
  return tmp;
}
inline matrix multiply(const matrix &a, const matrix &b) {
  matrix c;
  memset(c.f, 0, sizeof(c.f));
  for (int i = 1; i <= 2; ++i) {
    for (int j = 1; j <= 2; ++j) {
      for (int k = 1; k <= 2; ++k) {
        c.f[i][j] += (long long)a.f[i][k] * b.f[k][j] % mod;
        c.f[i][j] %= mod;
      }
    }
  }
  return c;
}
long long x, t;
int main() {
  scanf("%lld%lld", &x, &t);
  if (!x) {
    puts("0");
    return 0;
  }
  x %= mod;
  ans.f[1][1] = x;
  ans.f[1][2] = 1;
  trans.f[1][1] = 2;
  trans.f[2][1] = mod - ksm(2, mod - 2);
  trans.f[2][2] = 1;
  for (; t; trans = multiply(trans, trans), t >>= 1)
    if (t & 1) ans = multiply(ans, trans);
  ans.f[1][1] <<= 1;
  printf("%d\n", ans.f[1][1] % mod);
  return 0;
}
