#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const long long mod = 1000000007;
bool ch(long long q) {
  long long qw = sqrt(q) + 1;
  for (int i = 2; i <= qw; i++) {
    if (q % i == 0) return false;
  }
  return true;
}
void solve() {
  long long n;
  cin >> n;
  int ans = 0;
  int q = sqrt(n) + 1;
  int c = n;
  int mx = 1;
  for (int i = 2; i <= q; i++) {
    while (c % i == 0) {
      mx = max(mx, i);
      c /= i;
    }
  }
  if (c != 1) {
    mx = max(mx, c);
  }
  if (mx == n) {
    cout << 1 << endl;
    return;
  }
  if (n == 2) {
    cout << 1 << endl;
    return;
  }
  if (n == 3) {
    cout << 1 << endl;
    return;
  }
  if (n == 4) {
    cout << 2 << endl;
    return;
  }
  if (n == 5) {
    cout << 1 << endl;
    return;
  }
  if (n == 6) {
    cout << 2 << endl;
    return;
  }
  if (n == 7) {
    cout << 1 << endl;
    return;
  }
  if (n & 1) {
    if (ch(n - 2)) {
      cout << 2 << endl;
    } else {
      cout << 3 << endl;
    }
  } else {
    cout << 2 << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
