#include <bits/stdc++.h>
unsigned long long int n;
unsigned long long int tab_comb[4001][4096];
unsigned long long int tab_grouping[4001][4096];
unsigned long long int grouping_count[4001];
int main() {
  std::cin >> n;
  for (unsigned long long int i = 1; i <= n; i++) {
    tab_grouping[i][1] = 1;
    tab_grouping[i][i] = 1;
  }
  tab_comb[0][0] = 1;
  for (unsigned long long int i = 1; i <= n; i++) {
    tab_comb[i][0] = tab_comb[i][i] = 1;
    for (unsigned long long int j = 1; j < i; j++) {
      tab_comb[i][j] = tab_comb[i - 1][j] + tab_comb[i - 1][j - 1];
      if (tab_comb[i][j] >= ((unsigned long long int)1000000007ll))
        tab_comb[i][j] -= ((unsigned long long int)1000000007ll);
    }
  }
  grouping_count[0] = 1;
  grouping_count[1] = 1;
  for (unsigned long long int i = 2; i <= n; i++) {
    unsigned long long int cnt = 2;
    for (unsigned long long int j = 2; j < i; j++) {
      tab_grouping[i][j] =
          tab_grouping[i - 1][j - 1] + tab_grouping[i - 1][j] * j;
      tab_grouping[i][j] %= ((unsigned long long int)1000000007ll);
      cnt += tab_grouping[i][j];
      if (cnt >= ((unsigned long long int)1000000007ll))
        cnt -= ((unsigned long long int)1000000007ll);
    }
    grouping_count[i] = cnt;
  }
  unsigned long long int result = 0;
  for (unsigned long long int i = 1; i <= n; i++) {
    result += tab_comb[n][i] * grouping_count[n - i];
    result %= ((unsigned long long int)1000000007ll);
  }
  std::cout << result << std::endl;
  return 0;
}
