#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 4001;
long long dp[maxn], c[maxn][maxn], s[maxn][maxn], sum[maxn];
long long pow(int k) {
  if (k == 0) return 1LL;
  if (k == 1) return 2LL;
  long long ans = pow(k >> 1);
  ans *= ans;
  if (k % 2) ans *= 2LL;
  return (ans % 1000000007);
}
void pre() {
  c[0][0] = c[1][0] = c[1][1] = 1LL;
  s[1][0] = 0;
  s[1][1] = 1LL;
  for (int i = 2; i <= n; i++) {
    c[i][0] = 1LL;
    s[i][0] = 0;
    for (int j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 1000000007;
      s[i][j] = (j * s[i - 1][j] + s[i - 1][j - 1]) % 1000000007;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= i; j++) sum[i] = (sum[i] + s[i][j]) % 1000000007;
}
int main() {
  cin >> n;
  pre();
  dp[1] = 1;
  dp[2] = 3;
  for (int i = 3; i <= n; i++) {
    dp[i] = 1;
    for (int j = 1; j <= n - 1; j++)
      dp[i] = (dp[i] + (dp[j] + sum[j]) * c[i - 1][j]) % 1000000007;
  }
  if (dp[n] < 0) dp[n] += 1000000007;
  printf("%I64d\n", dp[n]);
  return 0;
}
