#include <bits/stdc++.h>
using namespace std;
const int lim = 1e3 + 7;
long long N;
bool isPrime(long long n) {
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  if (n < 2) return false;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0) return false;
  return true;
}
void solve() {
  cin >> N;
  if (isPrime(N))
    cout << 1;
  else if (N % 2 == 0)
    cout << 2;
  else if (isPrime(N - 2))
    cout << 2;
  else
    cout << 3;
}
int main() {
  if (fopen("d:\\lmo.in", "r") != NULL) {
    freopen("d:\\lmo.in", "r", stdin);
  } else if (fopen("/media/luismo/Pablo's Destruction/lmo.in", "r") != NULL) {
    freopen("/media/luismo/Pablo's Destruction/lmo.in", "r", stdin);
  }
  cin.sync_with_stdio(false);
  cin.tie(0);
  solve();
}
