#include <bits/stdc++.h>
using namespace std;
bool comp[3000010];
void sieve(int n) {
  for (int i = 2; i <= n; ++i) {
    if (!comp[i]) {
      for (int j = i + i; j <= n; j += i) {
        comp[j] = true;
      }
    }
  }
}
void solve() {
  int n;
  cin >> n;
  for (int m = 1; m <= 1000; ++m) {
    int val = n * m + 1;
    if (comp[val]) {
      cout << m << "\n";
      break;
    }
  }
}
int main() {
  sieve(2000000);
  int k = 1;
  for (; k <= 1; ++k) {
    solve();
  }
}
