#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  bool check = true;
  cin >> n;
  for (a = 2; a <= sqrt(n); a++) {
    if (n % a == 0) check = false;
  }
  if (check == true) {
    cout << 1;
    return 0;
  }
  if (n % 2 == 0)
    cout << 2;
  else {
    check = true;
    for (a = 2; a <= sqrt(n - 2); a++) {
      if ((n - 2) % a == 0) check = false;
    }
    if (check == true) {
      cout << 2;
      return 0;
    }
    cout << 3;
  }
  return 0;
}
