#include <bits/stdc++.h>
using namespace std;
bool isprime(int num) {
  int temp = sqrt(num);
  for (int i = 2; i <= temp; i++) {
    if (num % i == 0) return false;
  }
  return true;
}
int solve() {
  int n;
  cin >> n;
  for (int m = 1; m <= 1000; m++) {
    if (!isprime(n * m + 1)) return m;
  }
}
int main() { cout << solve(); }
