#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long int> v(1000005);
  long long int i, n, j;
  for (i = 2; i < 1000005; i++) {
    j = i * 2;
    while (j <= 1000005) {
      v[j] = 1;
      j += i;
    }
  }
  cin >> n;
  j = 1;
  for (j = 1; j < 1001; j++) {
    if (v[n * j + 1] != 0) {
      cout << j;
      break;
    }
  }
}
