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