#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<bool> prime(pow(10, 6), false);
  for (int i = 2; i < pow(10, 6); i++) {
    if (prime[i] == false) {
      for (int j = 2 * i; j < pow(10, 6); j += i) prime[j] = true;
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= 1000; i++) {
    if (prime[(n * i) + 1] == true) {
      cout << i;
      break;
    }
  }
}
