#include <bits/stdc++.h>
using namespace std;
vector<int> primes;
bool isPrime(int n) {
  bool ans = true;
  for (int i = 0; i < primes.size() && ans && primes[i] < n; ++i)
    if (n % primes[i] == 0) ans = false;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(9);
  cout << fixed;
  int c = 350000;
  vector<int> isPr(c, 1);
  for (int i = 2; i < c; ++i) {
    if (isPr[i]) {
      primes.push_back(i);
      for (int j = i + i; j < c; j += i) isPr[j] = 0;
    }
  }
  int n;
  cin >> n;
  if (isPrime(n)) {
    cout << 1;
    return 0;
  }
  for (int i = 2; i <= min(10000, n - 2); ++i) {
    if (isPrime(i) && isPrime(n - i)) {
      cout << 2;
      return 0;
    }
  }
  cout << 3;
  return 0;
}
