#include <bits/stdc++.h>
using namespace std;
long long int modularExponentiation(long long int x, long long int y,
                                    long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool isPrime(long long 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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1;
  for (int _case = 0; _case < T; _case++) {
    long long int n;
    cin >> n;
    if (isPrime(n))
      cout << 1 << endl;
    else if (n % 2 == 0 || isPrime(n - 2))
      cout << 2 << endl;
    else
      cout << 3 << endl;
  }
  return 0;
}
