#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& in, pair<T, T>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, const pair<T, T>& a) {
  out << a.first << ' ' << a.second;
  return out;
}
const int INF = 0x3f3f3f3f;
const int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
bool is_prime(int64_t x) {
  for (int64_t i = 2; i * i <= x; i++) {
    if (!(x % i)) return 0;
  }
  return 1;
}
int64_t ans(int64_t x) {
  if (x <= 3) return 1;
  if (x & 1) return 1 + (!is_prime(x) ? min(ans(x - 3), ans(x - 2)) : 0);
  return 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int64_t x;
  cin >> x;
  cout << ans(x) << '\n';
  return 0;
}
