#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
bool check(int n) {
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (int i = 3; i <= n / i + 1; ++i)
    if (n % i == 0) return false;
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int m = 1; m <= 1e3 + 1; ++m) {
    if (!check(n * m + 1)) {
      cout << m;
      return 0;
    }
  }
  return 0;
}
