#include <bits/stdc++.h>
using namespace std;
const long long maxn = (long long)5e5;
const long long linf = (long long)1e16;
const long long mod = (long long)1e9 + 7;
long long n;
long long f(long long x) {
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return 1;
    }
  }
  return 0;
}
int main() {
  cin >> n;
  if (n == 1) {
    cout << 3;
    return 0;
  }
  if (n % 2 == 1 && n > 1) {
    cout << 1;
    return 0;
  }
  for (long long i = 2; i <= maxn; i++) {
    if (f(n * i + 1)) {
      cout << i;
      return 0;
    }
  }
  return 0;
}
