#include <bits/stdc++.h>
using namespace std;
long long step(long long k) {
  if (k == 0) return 1;
  if (k == 1) return 2;
  if (k % 2 == 0) {
    long long x = (long long)step(k / 2);
    x = (x * x) % 1000000007;
    return x;
  } else {
    long long x = (long long)step(k / 2);
    x = (((x * x) % 1000000007) * 2) % 1000000007;
    return x;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long x, k;
  cin >> x >> k;
  if (x == 0) {
    cout << "0";
    return 0;
  }
  x = x % 1000000007;
  long long d = step(k + 1);
  x = (x * d) % 1000000007;
  x = (x + 1000000007 - step(k) + 1) % 1000000007;
  cout << x;
  return 0;
}
