#include <bits/stdc++.h>
using namespace std;
bool check(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
int solve(int n) {
  if (n == 2)
    return 1;
  else if (n % 2 == 0)
    return 2;
  else {
    if (check(n))
      return 1;
    else {
      if (check(n - 2))
        return 2;
      else
        return 3;
    }
  }
}
int main() {
  int n;
  while (cin >> n) cout << solve(n) << endl;
}
