#include <bits/stdc++.h>
using namespace std;
const int BIGNUM = 1000000007;
const int limit = 4002;
long long int nCk[limit][limit] = {0};
long long int Bell[limit] = {0};
long long int solutions[limit] = {0};
void getSolutions() {
  solutions[0] = 0;
  solutions[1] = 1;
  long long int sum = 0;
  for (int i = 0; i < limit; i++) {
    sum = 0;
    for (int j = 0; j < i; j++) {
      sum += nCk[i][j + 1] * Bell[i - j - 1];
      sum %= BIGNUM;
    }
    solutions[i] = sum;
  }
}
void getBell() {
  Bell[0] = 1;
  Bell[1] = 1;
  long long int sum = 0;
  for (int i = 0; i < limit; i++) {
    if (i < 2) continue;
    sum = 0;
    for (int j = 0; j < i; j++) {
      sum += nCk[i - 1][j] * Bell[j];
      sum %= BIGNUM;
    }
    Bell[i] = sum;
  }
}
void getNck() {
  for (int i = 0; i < limit; i++) {
    nCk[0][i] = 0;
    nCk[i][0] = 1;
  }
  for (int i = 0; i < limit - 1; i++) {
    for (int j = 0; j < i + 1; j++) {
      nCk[i + 1][j + 1] = (nCk[i][j] + nCk[i][j + 1]) % BIGNUM;
    }
  }
}
int main(void) {
  int n;
  cin >> n;
  getNck();
  getBell();
  getSolutions();
  cout << solutions[n];
  return 0;
}
