#include <bits/stdc++.h>
using namespace std;
int n, a;
int main() {
  cin >> a;
  int f = 0;
  n = sqrt(a);
  for (int i = 2; i <= n; i++)
    if (a % i == 0 && i != a) {
      f = 1;
      break;
    }
  if (f == 0) {
    cout << 1;
    return 0;
  }
  if (a % 2 == 0) {
    cout << 2;
    return 0;
  }
  f = 0;
  a = a - 2;
  n = sqrt(a);
  for (int i = 2; i <= n; i++)
    if (a % i == 0) {
      f = 1;
      break;
    }
  if (f == 0) {
    cout << 2;
    return 0;
  } else
    cout << 3;
}
