#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T zz) {
  return zz < 0 ? -zz : zz;
}
template <typename T>
inline T sqr(T zz) {
  return zz * zz;
}
const int MAGIC = 1000500;
vector<int> used;
vector<int> primes;
bool is_prime(int n) {
  for (int p : primes) {
    if (p * p > n) break;
    if (n % p == 0) return false;
  }
  return true;
}
int main() {
  used = vector<int>(MAGIC, 0);
  for (int i = 2; i < MAGIC; ++i) {
    if (!used[i]) {
      primes.push_back(i);
      for (int j = i; j < MAGIC; j += i) {
        used[j] = true;
      }
    }
  }
  int n;
  cin >> n;
  if (is_prime(n) == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (n % 2 == 0) {
    cout << 2 << endl;
    return 0;
  }
  if (is_prime(n - 2)) {
    cout << 2 << endl;
    return 0;
  }
  cout << 3 << endl;
  return 0;
}
