#include <bits/stdc++.h>
using namespace std;
const int N = 20000005;
int n, k, x, t, a, b, m;
string s;
vector<int> v;
bool isPrime(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
void solve() {
  cin >> n;
  if (isPrime(n)) {
    cout << 1;
    return;
  }
  if (n % 2 == 0 || isPrime(n - 2)) {
    cout << 2;
  } else {
    cout << 3;
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
