#include <bits/stdc++.h>
using namespace std;
bool isprime(long long n) {
  if (n == 2) return true;
  if (n < 2 || n % 2 == 0) return false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  int n;
  cin >> n;
  if (isprime(n))
    cout << 1 << endl;
  else if (n % 2 == 0)
    cout << 2 << endl;
  else if (isprime(n - 2))
    cout << 2 << endl;
  else
    cout << 3 << endl;
  return 0;
}
