#include <bits/stdc++.h>
using namespace std;
long long int f[5011], inv[5011];
long long int exp(long long int a, long long int b) {
  long long int r = 1;
  while (b) {
    if (b & 1) r = r * a % 1000000007, r %= 1000000007;
    a = a * a % 1000000007;
    b /= 2;
  }
  return r % 1000000007;
}
void prec() {
  int i, j;
  f[0] = inv[0] = 1;
  for (i = 1; i < 5011; ++i) {
    f[i] = f[i - 1] * i % 1000000007;
    f[i] %= 1000000007;
    inv[i] = inv[i - 1] * exp(i, 1000000007 - 2) % 1000000007;
    inv[i] %= 1000000007;
  }
}
long long int chose(long long int n, long long int k) {
  if (n < k) return 0;
  long long int r = f[n];
  r = r * inv[k];
  r %= 1000000007;
  r = r * inv[n - k];
  return r % 1000000007;
}
long long int dp[5011][5011];
long long int fo(long long int n, long long int k) {
  if (n == 0 && k == 0) return 1;
  if (n == 0 || k == 0) return 0;
  if (dp[n][k] != -1) return dp[n][k];
  long long int ans = 0;
  ans = fo(n - 1, k - 1);
  ans %= 1000000007;
  ans = ans + k * fo(n - 1, k) % 1000000007;
  ans %= 1000000007;
  dp[n][k] = ans;
  return ans;
}
long long int sol(long long int n, long long int i) {
  if (i == 0) return exp(2, n);
  if (n == 0) return 0;
  if (i > n) return 0;
  long long int p = 1;
  for (long long int j = n; j >= 1 && j >= n - i + 1; --j)
    p = p * j, p %= 1000000007;
  p = p * exp(2, max(0ll, n - i));
  return p % 1000000007;
}
int solve() {
  long long int n, i, j, k, m, x;
  cin >> n >> k;
  long long int p = 0;
  for (i = 0; i <= k; ++i) {
    x = fo(k, i);
    x = x * sol(n, i);
    x %= 1000000007;
    p += x;
    p %= 1000000007;
  }
  cout << (p + 1000000007) % 1000000007 << "\n";
  return 0;
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  prec();
  memset(dp, -1, sizeof(dp));
  while (t--) {
    solve();
  }
  return 0;
  ;
}
