#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
signed main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  auto f = [](long long n) {
    for (long long i = 2; i * i <= n; i++) {
      if (n % i == 0) return 0;
    }
    return 1;
  };
  if (f(n))
    cout << 1 << '\n';
  else if (n % 2 == 0 || f(n - 2))
    cout << 2 << '\n';
  else
    cout << 3 << '\n';
  return 0;
}
