#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
bool prime[N];
int main() {
  for (int i = 0; i < N; i++) prime[i] = true;
  for (int i = 2; i * i < N; i++) {
    if (prime[i])
      for (int j = i + i; j < N; j += i) prime[j] = false;
  }
  int n;
  cin >> n;
  if (n % 2 == 1) {
    cout << (n == 1 ? 3 : 1);
  } else {
    int ans = -1;
    for (int i = 1; i <= 1000; i++) {
      if (!prime[n * i + 1]) {
        ans = i;
        break;
      }
    }
    assert(ans != -1);
    cout << ans;
  }
  return 0;
}
