#include <bits/stdc++.h>
int const MAX = 4005;
int const MOD = 1e9 + 7;
long long dp[MAX][MAX];
int main() {
  int n;
  scanf("%d", &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] = (dp[i][j - 1] + dp[i - 1][j - 1]) % MOD;
  }
  printf("%I64d\n", dp[n][n - 1]);
}
