#include <bits/stdc++.h>
using namespace std;
bool primo(int p) {
  for (int i = 2; i < p; i++) {
    if (p % i == 0) {
      return false;
    }
  }
  return true;
}
int main() {
  int a, temp = 0, m = 1;
  cin >> a;
  while (primo(a * m + 1)) {
    m++;
  }
  cout << m;
}
