#include <bits/stdc++.h>
using namespace std;
const int INF = 100000000;
int n, m;
bool is_prime(int num) {
  for (int i = 2; i <= sqrt(num); i++) {
    if (num % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  cin >> n;
  for (int m = 1; m <= 1000; m++) {
    int nn = n * m + 1;
    if (is_prime(nn) == 0) {
      cout << m;
      return 0;
    }
  }
}
