#include <bits/stdc++.h>
using namespace std;
bool isPrime(unsigned int n) {
  if (n <= 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  static unsigned int d, finish;
  finish = sqrt(n) + 1;
  for (d = 3; d <= finish; d += 2) {
    if (n % d == 0) return false;
  }
  return true;
}
void evadeTax(unsigned int n) {
  if (isPrime(n)) {
    cout << 1;
  } else if (n % 2 == 0) {
    cout << 2;
  } else if (isPrime(n - 2)) {
    cout << 2;
  } else
    cout << 3;
}
int main() {
  unsigned int n;
  cin >> n;
  evadeTax(n);
  return 0;
}
