#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  int i, f = 0;
  int x = 100000;
  bool prime[x + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= x; p++) {
    if (prime[p] == true) {
      for (int i = p * 2; i <= x; i += p) prime[i] = false;
    }
  }
  for (m = 1; m <= 1000; m++) {
    if (!prime[(n * m) + 1]) {
      f = 1;
      break;
    }
  }
  cout << m;
  return 0;
}
