#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  if (n > 2 && n % 2)
    cout << 1 << endl;
  else if (n > 2 && n % 2 == 0) {
    if (n == 998)
      cout << 1000 << endl;
    else if (n == 1000)
      cout << 2 << endl;
    else
      cout << (n + 2) % 1000 << endl;
  } else if (n == 1)
    cout << 3 << endl;
  else if (n == 2)
    cout << 4 << endl;
  return 0;
}
