#include <bits/stdc++.h>
using namespace std;
void solve(int test_number);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.setf(ios::fixed);
  cout.precision(9);
  cerr.setf(ios::fixed);
  cerr.precision(3);
  int n = 1;
  for (int i = 0; i < n; i++) {
    solve(i);
  }
}
bool check_prime(int n) {
  if (n == 1) {
    return false;
  }
  if (n == 2 || n == 3) {
    return true;
  }
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
void solve(int test_number) {
  int n;
  cin >> n;
  if (check_prime(n)) {
    cout << 1 << endl;
    return;
  }
  if (n % 2 == 0) {
    cout << 2 << endl;
    return;
  }
  if (check_prime(n - 2)) {
    cout << 2 << endl;
    return;
  }
  cout << 3 << endl;
}
