#include <bits/stdc++.h>
using namespace std;
bool st[100005];
void sieve(unsigned long long last = 100000) {
  for (unsigned long long i = 2; i * i <= last; i++) {
    if (st[i]) {
      for (unsigned long long j = i * i; j <= last; j += i) {
        st[j] = false;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  unsigned long long number, ct = 0;
  memset(st, true, sizeof(st));
  cin >> number;
  sieve();
  if (number % 2 != 0)
    cout << 3 << endl;
  else {
    while (st[number * ct + 1]) {
      ct += 1;
    }
    cout << ct << endl;
  }
  return 0;
}
