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