#include <bits/stdc++.h>
using namespace std;
unsigned long long n;
void read() { cin >> n; }
void solve() {
  if (n == 2) {
    cout << 1 << endl;
    return;
  }
  if (n % 2 == 0) {
    cout << 2 << endl;
    return;
  }
  bool pr = 1;
  for (unsigned long long i = 2; i * i <= n; i++)
    if (n % i == 0) {
      pr = 0;
      break;
    }
  if (pr) {
    cout << 1 << endl;
    return;
  }
  pr = 1;
  for (unsigned long long i = 2; i * i <= n - 2; i++)
    if ((n - 2) % i == 0) {
      pr = 0;
      break;
    }
  if (pr) {
    cout << 2 << endl;
    return;
  }
  cout << 3 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
