#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
bool isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  if (isprime(n)) {
    cout << 1;
  } else if (n % 2 == 0) {
    cout << 2;
  } else if (isprime(n - 2)) {
    cout << 2;
  } else {
    cout << 3;
  }
  return 0;
}
