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