#include <bits/stdc++.h>
using namespace std;
const int MAX = 1200000;
int n;
int ansg[5000];
int dp[5000][5000];
int power(int a, int step) {
  int res = 1;
  while (step) {
    if (step & 1) {
      res = (1LL * res * a) % 1000000007;
    }
    a = (1LL * a * a) % 1000000007;
    step >>= 1;
  }
  return res;
}
int main() {
  cin >> n;
  dp[0][0] = 1;
  ansg[0] = 1;
  dp[1][1] = 1;
  for (int(i) = (1); i < (n + 1); ++(i)) {
    ansg[i] = 0;
    for (int(j) = (1); j < (i + 1); ++(j)) {
      ansg[i] = (ansg[i] + dp[i][j]) % 1000000007;
      dp[i + 1][j + 1] = (dp[i][j] + dp[i + 1][j + 1]) % 1000000007;
      dp[i + 1][j] = (1LL * j * dp[i][j] + dp[i + 1][j]) % 1000000007;
    }
  }
  int ans = 0;
  long long f = 1;
  long long ch = n;
  long long d = 1;
  for (int(k) = (n + 1) - 1; (k) >= (1); --(k)) {
    ans = (ans + 1LL * f * ansg[n - k]) % 1000000007;
    f = (f * ch) % 1000000007;
    f = (f * power(d, 1000000007 - 2)) % 1000000007;
    ch--;
    d++;
  }
  cout << ans << endl;
  return 0;
}
