#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n == 2) return true;
  long long sq = sqrt(n * 1.0) + 1;
  for (int i = 2; i <= sq; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= 1000; ++i) {
    if (!isPrime(n * i + 1)) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}
