#include <bits/stdc++.h>
using namespace std;
bool checkprime(int x) {
  int i;
  bool check = true;
  for (i = 2; i < x; i++) {
    if (x % i == 0) {
      check = false;
      break;
    }
  }
  return check;
}
int main() {
  int n;
  cin >> n;
  if (n == 1)
    cout << 3;
  else if ((n % 2 != 0) and (n != 1))
    cout << 1;
  else {
    int m;
    for (m = 1; m <= 1000; m++) {
      if (checkprime(n * m + 1) == false) {
        cout << m;
        break;
      }
    }
  }
  return 0;
}
