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