#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  if (n % 2 == 0 && n != 2)
    cout << "2\n";
  else {
    bool is_prime = true;
    for (long long i = 2; i * i <= n; ++i) {
      if (n % i == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime) return cout << "1\n", 0;
    n -= 2;
    is_prime = true;
    for (long long i = 2; i * i <= n; ++i) {
      if (n % i == 0) {
        is_prime = false;
        break;
      }
    }
    cout << (is_prime ? "2\n" : "3\n");
  }
}
