#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 1000; i++) {
    int flag = 0;
    int m = (i * n) + 1;
    if (m == 2 || m == 3) {
      continue;
    }
    for (int j = 2; j * j <= m; j++) {
      if (m % j == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      cout << i << endl;
      break;
    }
  }
}
