#include <bits/stdc++.h>
const int N = 1000005;
long long n, k;
inline int ksm(register long long L) {
  register int x = 2, ans = 1;
  while (L)
    L& 1 ? ans = (0ll + ans) * x % 1000000007 : 0,
           x = (0ll + x) * x % 1000000007, L >>= 1;
  return ans;
}
int main() {
  scanf("%lld%lld", &n, &k);
  if (!n) return putchar('0'), 0;
  n = ((n % 1000000007) * ksm(k + 1) % 1000000007 - ksm(k) + 1) % 1000000007;
  printf("%lld", n < 0 ? n + 1000000007 : n);
  return 0;
}
