#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
int mox[8] = {1, -1, 0, 0, 1, -1, 1, -1};
int moy[8] = {0, 0, 1, -1, -1, -1, 1, 1};
char mover[4] = {'D', 'U', 'R', 'L'};
const long long INF = (1LL << 61);
const int inf = (int)2e9;
const long double PI = acos(-1);
const long double EPS = 1e-9;
bool debug;
using namespace std;
void solve();
int main() {
  debug = 0;
  cout.precision(30);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
const int N = 95;
const int lg = 26;
long long n, ans;
bool prime() {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return 0;
  return 1;
}
void solve() {
  cin >> n;
  if (prime())
    cout << 1 << endl;
  else if (n % 2 == 0)
    cout << 2 << endl;
  else {
    n -= 2;
    if (prime())
      cout << 2 << endl;
    else
      cout << 3 << endl;
  }
}
