#include <bits/stdc++.h>
using namespace std;
bool isprime(long long val) {
  for (long long i = 2; i * i <= val; i++) {
    if (val % i == 0) return false;
  }
  return true;
}
int main() {
  long long n;
  cin >> n;
  if (n != 2 && n % 2 == 0) {
    cout << 2 << endl;
    exit(0);
  }
  if (isprime(n) || n == 2) {
    cout << 1 << endl;
    exit(0);
  }
  if (isprime(n - 2)) {
    cout << 2 << endl;
    exit(0);
  }
  cout << 3 << endl;
}
