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