#include <bits/stdc++.h>
using namespace std;
int cha(long long k) {
  for (int i = 2; i <= sqrt(k); i++) {
    if (k % i == 0) return 0;
  }
  return 1;
}
int main() {
  long long n;
  while (cin >> n) {
    if (cha(n)) {
      cout << "1" << endl;
    } else {
      if (n % 2) {
        if (cha(n - 2))
          cout << "2" << endl;
        else
          cout << "3" << endl;
      } else
        cout << "2" << endl;
    }
  }
}
