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