#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MOD = 1000000007;
const int N = 105;
int n;
int judge(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int main() {
  cin >> n;
  int ans;
  if (judge(n))
    ans = 1;
  else if (n % 2 == 0)
    ans = 2;
  else if (judge(n - 2))
    ans = 2;
  else
    ans = 3;
  printf("%d\n", ans);
}
