#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
signed main() {
  long long n, m;
  cin >> n;
  for (m = 1; m <= 1000; m++) {
    if (isPrime((n * m) + 1) == false) {
      break;
    }
  }
  cout << m;
  return 0;
}
