#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100500;
long long div(long long n) {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return i;
  return n;
}
int pr[MAXN];
int dp[MAXN];
int stup(int n) {
  for (int i = 2; i <= n; i++) dp[i] = pr[i] ? i / pr[i] : 1;
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= i - 2; j++) dp[i] = min(dp[i], dp[j] + dp[i - j]);
  }
  return dp[n];
}
int main() {
  for (int i = 2; i < MAXN; i++) {
    if (pr[i] == 0) {
      for (int j = 2 * i; j < MAXN; j += i)
        if (pr[j] == 0) pr[j] = i;
    }
  }
  long long n;
  cin >> n;
  if (n < 100)
    cout << stup(n);
  else if (div(n) == n)
    cout << 1;
  else {
    if (div(n - 2) == n - 2 || n % 2 == 0)
      cout << 2;
    else
      cout << 3;
  }
  return 0;
}
