#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n < 2) return 0;
  if (n < 4) return 1;
  if (n % 2 == 0 or n % 3 == 0) return 0;
  for (long long i = 5; i * i <= n; i += 6)
    if (n % i == 0 or n % (i + 2) == 0) return 0;
  return 1;
}
long long modexpo(long long x, long long p) {
  long long res = 1;
  x = x % 1000000007;
  while (p) {
    if (p % 2) res = res * x;
    p >>= 1;
    x = x * x % 1000000007;
    res %= 1000000007;
  }
  return res;
}
long long max(long long a, long long b) { return (a > b ? a : b); }
long long min(long long a, long long b) { return (a < b ? a : b); }
struct edge {
  long long u, v, w;
  edge(long long a, long long b, long long c) {
    u = a;
    v = b;
    w = c;
  }
};
struct compare {
  bool operator()(const edge a, const edge b) const { return a.w < b.w; }
};
long long modInverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long x, k;
  cin >> x >> k;
  if (x == 0) {
    cout << 0 << "\n";
    return 0;
  }
  if (k == 0) {
    long long a = 2 * x;
    a %= 1000000007;
    cout << a << "\n";
    return 0;
  }
  x %= 1000000007;
  long long a = modexpo(2, k);
  long long b = a - 1;
  if (b < 0) {
    b += 1000000007;
  }
  a *= x;
  a %= 1000000007;
  a = a - b;
  a %= 1000000007;
  a--;
  if (a < 0) {
    a += 1000000007;
  }
  long long e = a + 1;
  e %= 1000000007;
  a = a * e;
  a %= 1000000007;
  long long c = modexpo(2, k);
  c *= x;
  c %= 1000000007;
  long long d = c + 1;
  d %= 1000000007;
  c = c * d;
  c %= 1000000007;
  long long ans = c - a;
  ans %= 1000000007;
  if (ans < 0) {
    ans += 1000000007;
  }
  long long z = modexpo(2, k);
  ans *= modInverse(z, 1000000007);
  ans %= 1000000007;
  cout << ans << "\n";
}
