#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long xx = 2e7;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
long long isprime(long long n) {
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return 0;
  }
  return 1;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  if (isprime(n)) {
    cout << 1 << '\n';
  } else if (n % 2 == 0 || isprime(n - 2)) {
    cout << 2 << '\n';
  } else
    cout << 3 << '\n';
}
