#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const int MOD = 1e9 + 7;
const int oo = MOD;
long long gcd(long long x, long long y) { return !y ? x : gcd(y, x % y); }
bool prime(long long n) {
  if (n == 1) return 0;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  long long n, ans;
  cin >> n;
  if (prime(n))
    ans = 1;
  else if (n % 2 == 0 || prime(n - 2))
    ans = 2;
  else
    ans = 3;
  cout << ans << '\n';
  return 0;
}
