#include <bits/stdc++.h>
using namespace std;
bool prime(long long a) {
  for (long long i = 2; i * i <= a; i++)
    if (a % i == 0) return false;
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1;; i++) {
    if (prime(i * n + 1) == 0) return cout << i << '\n', 0;
  }
}
