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