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