#include <bits/stdc++.h>
int main() {
  int n, s, p, i, c;
  scanf("%d", &n);
  s = 1;
  while (1) {
    c = 0;
    p = n * s + 1;
    for (i = 2; i < p; i++) {
      if (p % i == 0) {
        c++;
      }
    }
    if (c >= 1) {
      break;
    }
    s++;
  }
  printf("%d\n", s);
  return 0;
}
