#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long cl(long double a) {
  if (a > (long long)a) {
    return (long long)a + 1;
  } else {
    return (long long)a;
  }
}
long long flr(long double a) { return (long long)a; }
long long n;
bool is_prime(long long n) {
  for (long long i = 2; (i * i) <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
void solve() {
  if (is_prime(n)) {
    cout << 1 << "\n";
    return;
  }
  if (n % 2 == 0 || is_prime(n - 2)) {
    cout << 2 << "\n";
    return;
  }
  cout << 3 << "\n";
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  solve();
}
