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