#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
  for (auto& x : v) o << x << ' ';
  return o;
}
bool isprime(int n) {
  if (n == 0 || n == 1) return false;
  if (n <= 3) return true;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  if (isprime(n))
    cout << 1 << endl;
  else if (n % 2 == 0)
    cout << 2 << endl;
  else {
    if (isprime(n - 2))
      cout << 2 << endl;
    else
      cout << 3 << endl;
  }
}
