#include <bits/stdc++.h>
using namespace std;
bool prime(long long n) {
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) return false;
  return true;
}
int solve(long long n) {
  if (prime(n)) return 1;
  if (n % 2 == 0) return 2;
  if (prime(n - 2)) return 2;
  return 3;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  cout << solve(n);
}
