#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<int> v = {0, 0, 1, 1, 2, 1};
  if (n < v.size()) {
    cout << v[n] << endl;
    return 0;
  }
  if (n % 2 == 0) {
    cout << 2 << endl;
    return 0;
  }
  bool pr = 1;
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) pr = 0;
  if (pr)
    cout << 1 << endl;
  else {
    bool pr = 1;
    n -= 2;
    for (long long i = 2; i * i <= n; ++i)
      if (n % i == 0) pr = 0;
    if (pr)
      cout << 2 << endl;
    else
      cout << 3 << endl;
  }
  return 0;
}
