#include <bits/stdc++.h>
using namespace std;
int isPrime(long long x) {
  for (long long d = 2; d * d <= x; d++) {
    if (x % d == 0) return 0;
  }
  return 1;
}
long long x;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> x;
  if (isPrime(x))
    cout << 1 << endl;
  else if (x % 2 == 0) {
    cout << 2 << endl;
  } else if (isPrime(x - 2)) {
    cout << 2 << endl;
  } else
    cout << 3 << endl;
  return 0;
}
