#include <bits/stdc++.h>
using namespace std;
bool isprime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  long long int n, m, x, z, i, j, k, a, b;
  bool c, s;
  cin >> n;
  c = isprime(n);
  if (c == true)
    cout << 1 << endl;
  else if (n % 2 == 0) {
    cout << 2 << endl;
  } else if (n % 2 != 0) {
    x = n - 2;
    s = isprime(x);
    if (s == true)
      cout << 2 << endl;
    else
      cout << 3 << endl;
  }
  return 0;
}
