#include <bits/stdc++.h>
using namespace std;
const int N = 10004;
bool check(int n) {
  int tmp = sqrt(n * 1.0);
  for (int i = 2; i <= tmp; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  int ans;
  if (n & 1) {
    if (check(n))
      ans = 1;
    else if (check(n - 2))
      ans = 2;
    else
      ans = 3;
  } else {
    if (n == 2)
      ans = 1;
    else
      ans = 2;
  }
  printf("%d\n", ans);
  return 0;
}
