#include <bits/stdc++.h>
bool is_prime(int n) {
  if (n <= 2) return n == 2;
  if (n % 2 == 0) return false;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n;
  std::cin >> n;
  for (int m = 1; m <= 1000; ++m) {
    if (!is_prime(n * m + 1)) {
      std::cout << m << '\n';
      break;
    }
  }
  return 0;
}
