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