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