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