#include <bits/stdc++.h>
using namespace std;
int n;
bool prime(int n) {
  if (n == 2) return true;
  if (n == 1) return false;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
void calc() {
  if (prime(n))
    cout << 1 << endl;
  else if (prime(n - 2))
    cout << 2 << endl;
  else
    cout << 3 << endl;
}
int main() {
  cin >> n;
  if (n == 2 || n == 3 || n == 5)
    cout << 1 << endl;
  else {
    if (n % 2 == 0)
      cout << 2 << endl;
    else
      calc();
  }
  return 0;
}
