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