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