#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 200;
int dp[5000][5000];
int main() {
  int n;
  cin >> n;
  dp[1][1] = 1;
  dp[2][1] = 1;
  dp[2][2] = 2;
  for (int i = 3; i <= n + 1; i++) {
    dp[i][1] = dp[i - 1][i - 1];
    for (int j = 2; j <= i; j++)
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % MOD;
  }
  cout << dp[n + 1][n];
  return 0;
}
