#include <bits/stdc++.h>
using namespace std;
inline bool isprime(long long n) {
  if (n == 1) return false;
  if (n == 2 || n == 3) return true;
  if (n % 6 != 1 && n % 6 != 5) return false;
  for (int i = 5; i * i <= n; i += 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int main() {
  long long x;
  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;
}
