#include <bits/stdc++.h>
int cekprima(int num) {
  for (int a = 2; a <= num / 2; a++) {
    if (num % a == 0) return -1;
  }
  return 1;
}
int main() {
  int num;
  scanf("%d", &num);
  int add = 1;
  int cek = cekprima((num * add) + 1);
  while (cek == 1) {
    add++;
    cek = cekprima((num * add) + 1);
  }
  printf("%d\n", add);
  return 0;
}
