#include <bits/stdc++.h>
using namespace std;
vector<long long> fact((const int)5e5 + 10), invfact((const int)5e5 + 10);
void EE(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return;
  }
  EE(b, a % b, x, y);
  long long temp = x;
  x = y;
  y = temp - (a / b) * y;
}
long long inverse(long long a, long long mod) {
  long long x, y;
  EE(a, mod, x, y);
  return (x + mod) % mod;
}
void build() {
  fact[0] = 1;
  for (long long i = 1; i < (const int)5e5 + 10; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
  invfact[(const int)5e5 + 10 - 1] =
      inverse(fact[(const int)5e5 + 10 - 1], 1000000007);
  for (long long i = (const int)5e5 + 10 - 1 - 1; i >= 0; i--)
    invfact[i] = (invfact[i + 1] * (i + 1)) % 1000000007;
}
long long ncr(long long n, long long r) {
  if (n < 0 || r < 0 || r > n) return 0;
  return (fact[n] * ((invfact[n - r] * invfact[r]) % 1000000007)) % 1000000007;
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
long long logy(long long x, long long y) {
  return ceil((long double)(log(x) / log(y)));
}
long long powe(long long a, long long b) {
  long long re = 1;
  while (b) {
    if (b & 1) re = (re * a);
    a = (a * a);
    b = b >> 1;
  }
  return re;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  long long p = sqrt(n);
  for (int i = 5; i <= p; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long check[10000007];
void solve() {
  long long n;
  cin >> n;
  if (isPrime(n)) {
    cout << "1\n";
    return;
  }
  if (n % 2 == 0) {
    cout << "2\n";
    return;
  }
  if (isPrime(n - 2)) {
    cout << "2";
    return;
  }
  cout << "3\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) solve();
}
