#include <bits/stdc++.h>
using namespace std;
long long int x, k;
long long int a[3][3];
long long int powmod(long long int a, long long int b) {
  long long int an = 1;
  while (b) {
    if (b & 1) {
      an = (an * a) % 1000000007;
    }
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return an;
}
long long int matpow(long long int b) {
  long long int an[3][3], c[3][3];
  for (int i = 1; i <= 2; i++)
    for (int j = 1; j <= 2; j++) an[i][j] = 0;
  for (int i = 1; i <= 2; i++) an[i][i] = 1;
  while (b) {
    if ((b & 1)) {
      for (int i = 1; i <= 2; i++)
        for (int j = 1; j <= 2; j++) c[i][j] = 0;
      for (int i = 1; i <= 2; i++)
        for (int j = 1; j <= 2; j++)
          for (int k = 1; k <= 2; k++)
            c[i][j] = (c[i][j] + an[i][k] * a[k][j]) % 1000000007;
      for (int i = 1; i <= 2; i++)
        for (int j = 1; j <= 2; j++) an[i][j] = c[i][j];
    }
    b >>= 1;
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= 2; j++) c[i][j] = 0;
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= 2; j++)
        for (int k = 1; k <= 2; k++)
          c[i][j] = (c[i][j] + a[i][k] * a[k][j]) % 1000000007;
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= 2; j++) a[i][j] = c[i][j];
  }
  if (x == 0) return 0;
  x %= 1000000007;
  long long int ans = (x * an[1][1] + an[2][1]) % 1000000007;
  ans = (2 * ans) % 1000000007;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> x >> k;
  long long int aa = powmod(2, 1000000007 - 2);
  aa *= -1;
  aa += 1000000007;
  aa %= 1000000007;
  a[1][1] = 2;
  a[1][2] = 0;
  a[2][1] = aa;
  a[2][2] = 1;
  cout << matpow(k) << '\n';
  return 0;
}
