#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e12;
bool check_prime(long long n) {
  long long tmp = sqrt(n);
  tmp += 1;
  for (long long i = 2; i < tmp; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  long long n;
  cin >> n;
  if (check_prime(n)) return cout << "1", 0;
  if (n % 2 == 0) return cout << "2", 0;
  if (check_prime(n - 2)) return cout << "2", 0;
  return cout << "3", 0;
}
