#include <bits/stdc++.h>
using namespace std;
long long lmod = 1e9 + 7;
long long bell[4002][4002];
long long modpow(int x) {
  if (x == 0) return 1;
  if (x == 1) return 2;
  long long f = modpow(x / 2);
  f = (f * f) % lmod;
  if (x & 1) f = (f * 2) % lmod;
  return f;
}
long long xi, yi, di;
void invmod(long long a, long long b) {
  if (b == 0) {
    xi = 1;
    yi = 0;
    di = a;
    return;
  }
  invmod(b, a % b);
  long long x1 = yi;
  yi = xi - (a / b) * yi;
  xi = x1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t, i, j, ind;
  long long n;
  long long px = 1, sx = 0;
  bell[0][0] = 1;
  bell[1][1] = 1;
  for ((i) = (2); (i) <= (4000); (i)++) {
    bell[i][1] = bell[i - 1][i - 1];
    for ((j) = (2); (j) <= (i); (j)++)
      bell[i][j] = (bell[i][j - 1] + bell[i - 1][j - 1]) % lmod;
  }
  cin >> n;
  for ((i) = (0); (i) <= (n - 1); (i)++) {
    long long mu = bell[i][i];
    mu = (mu * px) % lmod;
    sx = (sx + mu) % lmod;
    px = (px * (n - i)) % lmod;
    invmod(i + 1, lmod);
    long long dinv = (xi > 0) ? xi : (xi + lmod);
    px = (px * dinv) % lmod;
  }
  cout << sx << "\n";
}
