#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  bool f = true, f2 = true;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      f = false;
      break;
    }
  }
  long long m = n - 2;
  for (long long i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      f2 = false;
      break;
    }
  }
  if (f == true)
    cout << 1 << endl;
  else if (n % 2 == 0)
    cout << 2 << endl;
  else if (f2 == true)
    cout << 2 << endl;
  else
    cout << 3 << endl;
}
