#include <bits/stdc++.h>
using namespace std;
const int NMAX = 4000;
const int MOD = 1e9 + 7;
int n;
int dp[1 + NMAX][1 + NMAX];
void computedp(int n) {
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][i - 1];
    for (int j = 1; j <= i; j++) {
      dp[i][j] = (1LL * (dp[i][j - 1] + dp[i - 1][j - 1])) % MOD;
    }
  }
}
int main() {
  cin >> n;
  computedp(n);
  cout << dp[n][n - 1] << '\n';
  return 0;
}
