#include <bits/stdc++.h>
using namespace std;
bool p(int n) {
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
int main() {
  int n, ans;
  cin >> n;
  if (p(n) == true)
    ans = 1;
  else if (n % 2 == 0 || p(n - 2))
    ans = 2;
  else
    ans = 3;
  cout << ans << endl;
  return 0;
}
