#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n) {
  if (n < 2) return 0;
  if (n == 2 || n == 3) return 1;
  if (n % 6 != 1 && n % 6 != 5) return 0;
  for (int i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) return 0;
  }
  return 1;
}
int main() {
  int x;
  cin >> x;
  if (is_prime(x))
    cout << 1 << endl;
  else if (x % 2 == 0)
    cout << 2 << endl;
  else if (is_prime(x - 2))
    cout << 2 << endl;
  else
    cout << 3 << endl;
  return 0;
}
