#include <bits/stdc++.h>
using namespace std;
long double det(long double x, long double y, long double z, long double t) {
  return x * t - y * z;
}
long long int pow(long long int n, long long int m) {
  if (m == 0) return 1;
  if (m == 1) return n % (int)1e9 + 7;
  long long int t = pow(n, m / 2) % (int)1e9 + 7;
  if (m % 2 == 0)
    return (t % (int)1e9 + 7 * t % (int)1e9 + 7) % (int)1e9 + 7;
  else
    return ((t % (int)1e9 + 7 * t % (int)1e9 + 7) % (int)1e9 +
            7 * (n % (int)1e9 + 7)) %
               (int)1e9 +
           7;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int x, y, i, z = 1, q = 1;
  cin >> x >> y;
  if (x == 0) return cout << 0, 0;
  x %= (int)1e9 + 7;
  x *= 2;
  x %= (int)1e9 + 7;
  x -= 1;
  if (y % 2) {
    y -= 1;
    q *= 2;
  }
  while (y > 0) {
    z = 2;
    for (i = 1; i <= (long long int)log2(y); i++) {
      z *= z;
      z %= (int)1e9 + 7;
    }
    y -= pow(2, (long long int)log2(y));
    q *= z;
    q %= (int)1e9 + 7;
  }
  long long int ans = q * x + 1;
  while (ans >= (int)1e9 + 7) ans -= (int)1e9 + 7;
  while (ans < 0) ans += (int)1e9 + 7;
  cout << ans;
  return 0;
}
