#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int fl = 0;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      fl = 1;
      break;
    }
  }
  if (fl == 0) {
    cout << 1;
    return 0;
  }
  if ((n & 1) == 0) {
    cout << 2;
    return 0;
  }
  int t = n - 2;
  fl = 0;
  for (long long int i = 2; i * i <= t; i++) {
    if (t % i == 0) {
      fl = 1;
      break;
    }
  }
  if (fl == 0)
    cout << 2;
  else
    cout << 3;
}
