#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 1, theory = 0;
  bool brek = false;
  cin >> n;
  for (; theory = n * m + 1; m++) {
    for (int i = 2; i <= theory / 2; i++) {
      if (theory % i == 0) {
        brek = true;
      }
      if (brek == true) break;
    }
    if (brek == true) break;
  }
  cout << m;
}
