#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long potega(long long a, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n % 2 == 1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    n /= 2;
  }
  return ans % MOD;
}
long long x, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> x >> k;
  if (x == 0) return cout << 0 << endl, 0;
  k %= (MOD - 1);
  long long DwaDoKa = potega(2, k) % MOD;
  x %= MOD;
  long long wynik = (((2 * DwaDoKa) % MOD) * x) % MOD;
  wynik = ((wynik - DwaDoKa + 1) % MOD + MOD) % MOD;
  cout << ((wynik % MOD) + MOD) % MOD << endl;
  getchar();
  getchar();
  return 0;
}
