#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
bool isprime(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  if (n <= 3)
    ans = 1;
  else if (n % 2 == 0)
    ans = 2;
  else if (isprime(n))
    ans = 1;
  else if (isprime(n - 2))
    ans = 2;
  else
    ans = 3;
  printf("%d\n", ans);
  return 0;
}
