#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  if (n == 2)
    printf("1\n");
  else if (n % 2 == 0)
    printf("2\n");
  else if (n % 2 == 1) {
    int t = 1;
    for (int i = 2; i * i <= n; i++) {
      if (n % i == 0) {
        t = 0;
        break;
      }
    }
    if (t == 1)
      printf("1\n");
    else {
      int cnt = 2;
      n = n - 2;
      for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
          cnt = 3;
        }
      }
      printf("%d\n", min(cnt, 3));
    }
  }
}
