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