#include <bits/stdc++.h>
using namespace std;
int isp(int d) {
  for (int i = 3; i < d / 2; ++i)
    if (d % i == 0) return 0;
  return 1;
}
int main() {
  int n, k = 1, t = 0, l;
  cin >> n;
  if (n % 2 != 0 && n != 1)
    cout << k;
  else {
    while (1) {
      if (k * n + 1 == 2) {
        cout << 3;
        break;
      } else if (isp(k * n + 1) == 0) {
        cout << k;
        break;
      } else {
        ++k;
      }
    }
  }
}
