#include <bits/stdc++.h>
using namespace std;
bool prime(int n) {
  int t = sqrt(n);
  for (int i = 2; i <= t; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n, ans = 0;
  cin >> n;
  if (n == 2 || n == 3 || prime(n))
    ans = 1;
  else if (n % 2 == 0)
    ans = 2;
  else if (prime(n - 2))
    ans = 2;
  else
    ans = 3;
  cout << ans;
}
