#include <bits/stdc++.h>
using namespace std;
auto fio = (ios::sync_with_stdio(0), cin.tie(0), cout.tie(0));
long long modinv(long long x) {
  long long r = 1, y = 1000000007 - 2;
  for (; y > 0; y >>= 1, x = x * x % 1000000007)
    if (y & 1) r = r * x % 1000000007;
  return r;
}
long long fpow(long long x, long long p) {
  long long r = 1;
  for (; p > 0; p >>= 1, x = x * x % 1000000007)
    if (p & 1) r = r * x % 1000000007;
  return r;
}
int32_t main() {
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> ways(k + 1);
  for (long long i = 1; i <= k; i++) {
    ways[i] = fpow(i, k);
    for (long long j = 1, c = 1; j < i; j++) {
      c = c * (i - j + 1) % 1000000007 * modinv(j) % 1000000007;
      ways[i] = (ways[i] - ways[j] * c % 1000000007 + 1000000007) % 1000000007;
    }
  }
  long long ans = 0;
  for (long long i = 1, c = 1; i <= k; i++) {
    c = c * (n - i + 1) % 1000000007 * modinv(i) % 1000000007;
    ans += ways[i] * c % 1000000007 * fpow(2, n - i);
    ans %= 1000000007;
  }
  cout << ans << endl;
}
