#include <bits/stdc++.h>
using namespace std;
bool isprime(int n) {
  if (n == 2) return true;
  bool ret = true;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ret = false;
      break;
    }
  }
  return ret;
}
int solve(int n) {
  if (isprime(n)) return 1;
  if (n % 2 == 0) return 2;
  if (isprime(n - 2)) return 2;
  return 3;
}
int main() {
  int n;
  cin >> n;
  cout << solve(n) << endl;
  return 0;
}
