#include <bits/stdc++.h>
using namespace std;
bool isPrime(int num);
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= 1000; i++) {
    if (!(isPrime(n * i + 1))) {
      cout << i;
      break;
    }
  }
  return 0;
}
bool isPrime(int num) {
  if (num <= 1)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  else {
    bool prime = true;
    int divisor = 3;
    double num_d = static_cast<double>(num);
    int upperLimit = static_cast<int>(sqrt(num_d) + 1);
    while (divisor <= upperLimit) {
      if (num % divisor == 0) prime = false;
      divisor += 2;
    }
    return prime;
  }
}
