#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  if (n == 1 || n == 2 || n == 3) {
    printf("1\n");
    return 0;
  }
  int f = 0, fl = 0, g = 0, h = 0;
  if (n % 2 == 0) {
    printf("2\n");
  } else {
    for (long long i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        f = 1;
        break;
      }
    }
    n -= 2;
    for (long long i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        g = 1;
        break;
      }
    }
    if (f == 0) {
      printf("1\n");
    } else if (g == 0)
      printf("2\n");
    else
      printf("3\n");
  }
}
