#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3F3F3F3F;
const long long INFLL = 0x3F3F3F3F3F3F3F3FLL;
bool isPrime(int n) {
  for (int i = 2; i <= n / i; ++i) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int main() {
  int n, ans = 0;
  cin >> n;
  if (n == 2 || n == 3 || isPrime(n)) {
    ans = 1;
  } else if (n % 2 == 0) {
    ans = 2;
  } else if (isPrime(n - 2)) {
    ans = 2;
  } else {
    ans = 3;
  }
  cout << ans;
  return 0;
}
