#include <bits/stdc++.h>
long long C[5000][5000], n, d[5000], mod = 1000000007;
int main() {
  scanf("%lld", &n);
  for (int i = 0; i <= n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  }
  d[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < i; j++)
      d[i] = (d[i] + C[i - 1][j] * d[i - 1 - j]) % mod;
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += d[i] * C[n][i] % mod;
  printf("%lld\n", ans % mod);
}
