#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Bigmod(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m)) * (Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
int checkprime(int n) {
  long long ck = 0;
  for (int j = 2; j * j <= n; j++) {
    if (n % j == 0) {
      ck = 1;
      break;
    }
  }
  if (ck == 0)
    return 1;
  else
    return 0;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  if (checkprime(n))
    cout << "1" << endl;
  else if (n % 2 == 0) {
    cout << "2";
  } else if (checkprime(n - 2))
    cout << "2" << endl;
  else
    cout << "3" << endl;
  return 0;
}
