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