Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). For example, if n = 6 then Funt has to pay 3 burles, while for n = 25 he needs to pay 5 and if n = 2 he pays only 1 burle.As mr. Funt is a very opportunistic person he wants to cheat a bit. In particular, he wants to split the initial n in several parts n1 + n2 + ... + nk = n (here k is arbitrary, even k = 1 is allowed) and pay the taxes for each part separately. He can't make some part equal to 1 because it will reveal him. So, the condition ni ≥ 2 should hold for all i from 1 to k.Ostap Bender wonders, how many money Funt has to pay (i.e. minimal) if he chooses and optimal way to split n in parts.

The first line of the input contains a single integer n (2 ≤ n ≤ 2·109) — the total year income of mr. Funt.

Print one integer — minimum possible number of burles that mr. Funt has to pay as a tax.

#include <bits/stdc++.h>

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define file ""
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <ll, ll> PII;
typedef double ld;

const int N = 2e6 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

ll n;

bool is_p(ll x) {
	for (ll i = 2; i * i <= x; ++i)
		if (x % i == 0) return 0;
	return 1;
}

ll D(ll x) {
	ll ans = 1;
	for (ll i = 2; i * i <= x; ++i)
		if (x % i == 0) ans = max(ans, x / i);
	return ans;
}

ll d[N];

int main () {
#ifdef machine42
	freopen (file"in", "r", stdin);
	freopen (file"out", "w", stdout);
	#endif
	ios_base :: sync_with_stdio (0);
	cin.tie(0);

	cin >> n;
	if (is_p(n)) {
		cout << 1 << "\n";
		return 0;
	}
	if (n % 2 == 0 || is_p(n - 2)) {
		cout << 2 << "\n";
		return 0;
	}
	cout << 2 + (n % 2) << "\n";

	return 0;
}

#include <cstdio>

inline bool check(int x) {
	for(int i = 2; i * i <= x; i++)
		if(x % i == 0)
			return false;
	return true;
}

int main() {
	int n;
	scanf("%d", &n);
	if(n == 1 || n == 2) puts("1");
	else if(n % 2 == 0) puts("2");
	else {
		if(check(n)) puts("1");
		else if(!check(n - 2)) puts("3");
		else puts("2");
	}
}

#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <math.h>

using namespace std;

#define VI vector<int>
#define VS vector<string>
#define VL vector<long long>
#define VB vector<bool>
#define VD vector<double>

bool IsPrime(int n) {
    for (int d = 2; d * d <= n; d++) {
        if (n % d == 0) {
            return false;
        }
    }
    return true;
}

int main(int argc, char ** argv) {
    int n;
    cin >> n;
    if (IsPrime(n)) {
        cout << 1;
    } else if ((n & 1) && !IsPrime(n - 2)) {
        cout << 3;
    } else {
        cout << 2;
    }
    return 0;
}

#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <iostream>
#include <algorithm>
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define PER(i,a,b) for(int i=(a);i>=(b);i--)
#define RVC(i,S) for(int i=0;i<(S).size();i++)
#define RAL(i,u) for(int i=fr[u];i!=-1;i=e[i].next)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
/*============ Header Template ============*/

int chk(int n) {
	int m=(int)sqrt(n+0.5);
	REP(i,2,m) if(n%i==0) return 0;
	return 1;
}

int main() {
	int n;
	read(n);
	if(chk(n)) {
		printf("1\n");
		return 0;
	} else if(n%2==0 || chk(n-2)) {
		printf("2\n");
	} else printf("3\n");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
bool isprime(int n) {
    if (n<2) return false;
    for (int i=2;i*i<=n;i++)
	    if(n%i==0) return false;
    return true;
}
int main() {
    cin>>n;
    if (isprime(n)) cout<<"1"<<endl;
        else if(n%2==0) cout<<"2"<<endl;
            else if(isprime(n-2)) cout<<"2"<<endl;
                else cout<<"3"<<endl;

    return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                int n, i;
                cin>>n;
                set<int> f;
                for(i = 1; i * i <= n; i++){
                        if(n % i == 0){
                                f.ins(i); f.ins(n/i);
                        }
                }
                if(sz(f) == 2) cout<<1;
                else{
                        int x = n - 2;
                        f.clear();
                        for(i = 1; i * i <=n; i++){
                                if(x % i == 0){
                                        f.ins(i); f.ins(n/i);
                                }
                        }
                        if(sz(f) == 2) cout<<2;
                        else{
                                if(n % 2 == 0) cout<<2;
                                else cout<<3;
                        }
                }
        }
        return 0;
}

#include<bits/stdc++.h>
using namespace std;
main()
{
	long long int r=0,i,n,k=0;
	cin>>n;
	for(i=2;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{r=1;
		break;}
	}
	for(i=2;i<=sqrt(n-2);i++)
	{
		if((n-2)%i==0)
		{k=1;
		break;}
	}
	if(r==0)
	cout<<"1";
	else if(k==0||n%2==0)
	cout<<"2";
	else
	cout<<"3";

}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool simple(int val){
	for(int i=2;i*i<=val;i++){
		if(val%i==0) return false;
	}
	return true;
}

map<int,int> mp;

int get_ans(int val){
	if(mp[val]!=0) return mp[val];
	if(simple(val)) return mp[val]=1;
	int ans = 1e9;
	int itr = 0;
	for(int j=val-2; j>1; j--){
		if(simple(j)){
			ans = min(ans, get_ans(val - j) + 1);
			itr++;
			if(itr >= 150) break;
		}
	}
	return mp[val] = ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	cout<<get_ans(n)<<endl;
	return 0;
}

#include <iostream>

using namespace std;
int k;
bool prim(int x)
{
    if(x==2)
        return 1;
    if(x%2==0)
        return 0;
    k=3;
    while(k*k<=x)
    {
        if(x%k==0)
            return 0;
        k+=2;
    }
    return 1;
}
int main()
{
    int s=0,n,nr;
    cin>>n;
    nr=n;
    if(prim(n)==1)
         cout<<"1";
    else
        if(n%2==0)
            cout<<"2";
        else
        {
        if(prim(n-2)==1)
            cout<<"2";
        else
            cout<<"3";
        }
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int, int> pair_ii;
typedef pair<long long, long long> pair_LL;
typedef pair<string, string> pair_ss;

#define fori(i, s, n) for (int i = s; i < n; ++i)
#define forir(i, f)   for (int i = f - 1; i >= 0; --i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz size()

namespace mod {

LL const modul = 1000000009;

LL sum(LL x, LL y) {
	return (x + y) % modul;
}

LL sub(LL x, LL y) {
	if (x > y) {
		return (x - y) % modul;
	}
	else {
		return (modul + x - y) % modul;
	}
}

LL mpl(LL x, LL y) {
	return (x * y) % modul;
}

LL bin_pow(LL x, LL e) {
	LL ans = 1;
	while (e) {
		if (e & 1) {
			ans = mod::mpl(ans, x);
		}
		x = mod::mpl(x, x);
		e >>= 1;
	}
	return ans;
}

LL rev(LL x) {
	LL ans = bin_pow(x, modul - 2);
	return ans;
}

LL div(LL x, LL y) {
	assert(y != 0);
	LL ans = x;
	ans = mod::mpl(ans, mod::rev(y));
	return ans;
}

}

void set_precise(int n) {
	cout << fixed;
	cout << setprecision(n);
}

bool check_prime(LL x) {
	for (LL i = 2; i * i <= x; ++i) {
		if (x % i == 0) {
			return 0;
		}
	}
	return 1;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	LL n;
	cin >> n;
	if (check_prime(n)) {
		cout << 1;
		return 0;
	}
	if (n % 2 == 0) {
		cout << 2;
		return 0;
	}
	if (check_prime(n - 2)) {
		cout << 2;
		return 0;
	}
	cout << 3;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
bool prime(long long num)
{
    for(long long i=2;i*i<=num;i++)
    {
        if(num%i==0)return 0;
    }
    return 1;
}
int main()
{
    scanf("%lld",&n);
    if(prime(n))printf("1");
    else if(n%2==0)printf("2");
    else if(prime(n-2))printf("2");
    else printf("3");
    return 0;
}

// Implementation practice (Have seen the editorial)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef set<int> si;
#define V vector
#define S set
#define P pair
#define M map;
#define PQ priority_queue
#define MOD 1000000007
#define INF (1<<30)
#define pb push_back
#define mp make_pair
#define loop(i, a) for (int i = 0; i < a; i++)
#define rloop(i, a) for (int i = a-1; i >= 0; i--)
#define show(a) cout << a << "\n"
#define showloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define itloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define debug(a) cout << #a << ": " << a << "\n"
#define mem(x,val) memset((x),(val),sizeof(x));
#define sz(x) ((int)x.size())
#define endl "\n"

bool is_prime(int a) {
	double len = sqrt(a + 10);
	len = min(((int)len + 1), a) - 1;
	bool is_prime = true;
	for (int i = 2; i <= len; i++) if (a % i == 0) {
		is_prime = false;
		break;
	}
	return is_prime;
}
int main() {
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	ios::sync_with_stdio(false);cin.tie(NULL);

	int n;
	cin >> n;
	if (is_prime(n)) cout << "1" << endl;
	else if (n % 2 == 0) cout << "2" << endl;
	else if (is_prime(n - 2)) cout << "2" << endl;
	else cout << "3" << endl;

	return 0;
}

#include <bits/stdc++.h>

#define rc(x) return cout<<x<<endl,0

using namespace std;

bool isPrime(int n){
	for(int i=2; i*i<=n; i++){
		if(n % i == 0)
			return false;
	}
	return true;
}

// D: Taxes
int main(){
	int n;
	cin >> n;
	if(isPrime(n)) rc(1);
	if(n%2==0) rc(2);
	else{
		if(isPrime(n-2)) rc(2);
		else rc(3);
	}

}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    cin >> n;
    if (n == 2)
    {
        cout << 1;
        return 0;
    }
    if (n % 2 == 1)
    {
        bool prime = true;
        for (ll i=3; i*i <= n; i++)
        {
            if (n%i == 0)
            {
                prime = false;
                break;
            }
        }
        if (prime)
        {
            cout << 1;
            return 0;
        }
        ll m = n - 2;
        prime = true;
        for (ll i=3; i*i <= m; i++)
        {
            if (m%i == 0)
            {
                prime = false;
                break;
            }
        }
        if (prime)
            cout << 2;
        else
            cout << 3;

    }
    else
        cout << 2;

    return 0;
}

#include <bits/stdc++.h>

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
	ll n;
	cin >> n;
	bool f = true;
	for(ll i = 2; i * i <= n; i++)
		if(n % i == 0)
			f = false;
	if(f){
		cout << 1;
		return;
	}
	if(n % 2 == 0){
		cout << 2;
		return;
	}
	f = true;
	n -= 2;
	for(ll i = 2; i * i <= n; i++)
		if(n % i == 0)
			f = false;
	if(f){
		cout << 2;
		return;
	}
	cout << 3;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}

#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include <vector>

using namespace std;

#define MAX_N 100000
typedef long long ll;
int T, N;
int ER[MAX_N];
vector<int> P;
int main()
{
	//freopen("input.txt", "r", stdin);
	scanf("%d", &N);
	for (int i = 2; i < MAX_N; i++)
	{
		if (ER[i] == 1) continue;
		P.push_back(i);
		for (int j = 2 * i; j < MAX_N; j += i) ER[j] = 1;
	}
	bool isPrime1 = true, isPrime2 = true;
	for (vector<int>::iterator iter = P.begin(); iter != P.end(); iter++)
	{
		if (*iter >= N) break;
		if (N % *iter == 0) isPrime1 = false;
		if (*iter < N-2 && (N - 2) % *iter == 0) isPrime2 = false;
	}

	int ans = 0;
	if (isPrime1) ans = 1;
	else if (isPrime2) ans = 2;
	else ans = N % 2 == 0 ? 2 : 3;
	printf("%d", ans);
}

#include <iostream>
#include <math.h>
#define ll long long
using namespace std;

const int N = 1e8;
bool b[N];

int main() {
	ll n;
	cin >> n;
	if(n == 3) {
		cout << 1;
		return 0;
	}
	if(n == 2) {
		cout << 1;
		return 0;
	}
	if(n % 2 == 0) {
		cout << 2;
		return 0;
	}
	n -= 2;
	int u = 0;
	for(int i = 3; i * i <= n; i += 2) {
		if(n % i == 0) {
			u = 1;
			break;
		}
	}
	n += 2;
	int t = 0;
	for(int i = 3; i * i <= n; i += 2) {
		if(n % i == 0) {
			t = 1;
			break;
		}
	}
	if(u == 0 && t == 1) {
		cout << 2;
		return 0;
	}
	else if(t == 1) {
		cout << 3;
		return 0;
	}
	cout << 1;
}

#include <bits/stdc++.h>
using namespace std;

#define badstr(x) #x
#define usaco(name) freopen(badstr(name.in),"r",stdin);freopen(badstr(name.out),"w",stdout);
#define segfault {int* ragequit = nullptr; int screwthis = *ragequit;};

#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define vpi vector<pii>
#define pll pair<ll,ll>
#define vpl vector<pll>
#define mp make_pair
#define f first
#define s second

#define f0r(i,a) for(int i=0;i<a;i++)
#define f0rr(i,a) for(int i=a-1;i>=0;i--)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define f1rr(i,a,b) for(int i=b-1;i>=a;i--)

#define eat(a) ll a;scanf("%I64d",&a);
#define eat2(a,b) eat(a);eat(b);
#define eat3(a,b,c) eat2(a,b);eat(c);
#define eat_arr(a,k) f0r(bAD,k)scanf("%d",a+bAD);
#define spit_arr(a,k) f0r(bAD,k){printf("%d",a[bAD]);printf(bAD==k-1?"\n":" ");};
#define spit(a) cout << a << "\n";

const int MOD = 1000000007;

bool isp(ll n) {
	ll k = 2;
	while (k*k<=n) {
		if (n%k==0) return 0;
		k++;
	}
	return 1;
}

int main() {
	eat(n);
	ll ans = 0;
	if (isp(n)) ans= 1;
	else if (n%2==0) {
		ans = 2;
	}
	else if (isp(n-2)) ans = 2;
	else ans = 3;
	cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;

#define mod 10000000007
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define mi map<int,int>
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define len(s) s.length()
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,1,size0f(a))
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define ld long double
const int N=1e9+1;
const long double pi=3.1415926535897;
ll exp(ll base,ll power, int p){if(!power)return 1; ll t=exp(base,power/2,p); if(power&1)return t*t*base%p; else return t*t%p;}

bool checkPrime(ll n){
    for(int i=2;i*i<=n;i++)
    if(n%i==0) return false;
    return true;
}

void solve(){
    ll n;
    cin>>n;
    if(checkPrime(n))cout<<1;
    else if(n%2==0)cout<<2;
    else if(checkPrime(n-2) or checkPrime(n-3))cout<<2;
    else cout<<3;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
      // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;//
bool prime(long long num)
{
    for(long long i=2;i*i<=num;i++)
        if(num%i==0)return 0;
    return 1;
}//
int main(void)
{
    cin>>n;
    if(prime(n))cout<<1<<endl;
    else if(n%2==0)cout<<2<<endl;
    else if(prime(n-2))cout<<2<<endl;
    else cout<<3<<endl;
}//

#include<bits/stdc++.h>
using namespace std;
int n,k;
bool flag=1;
int main()
{
	scanf("%d",&n);
	if(n==1)
	{
		cout<<1;
		return 0;
	}
	k=sqrt(n);
	for(int i=2;i<=k&&flag;i++)
	{
		if(n%i) continue;
		flag=0;
	}
	if(flag)
	{
		cout<<1;
	}
	else
	{
		if(n%2)
		{
			n-=2;
			flag=1;
			k=sqrt(n);
			for(int i=2;i<=k&&flag;i++)
			{
				if(n%i) continue;
				flag=0;
			}
			if(flag) cout<<2;
			else cout<<3;
		 }
		else cout<<2;
	}
}

#include<cstdio>
using namespace std;
int n;
bool check(int n)
{
	if(n<2) return 0;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0) return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	if(check(n)) putchar('1');
	else if(!(n&1)) putchar('2');
	else if(check(n-2)) putchar('2');
	else putchar('3');
}

#include <algorithm>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define FOR(i,n) for(int i=0;i<(n);++i)
#define FORU(i,j,k) for(int i=(j);i<=(k);++i)
#define FORD(i,j,k) for(int i=(j);i>=(k);--i)

using lli = long long int;

using namespace std;

const long long int oo = 1000*1000*1000;

struct Coord
{
	int x, y;
	Coord(int x = 0, int y = 0) : x(x), y(y) {}
	Coord operator + (const Coord& droite) const
	{
		return Coord(x + droite.x, y + droite.y);
	}
};

vector<lli> prime;

bool isPrime(lli n)
{
	for(auto i : prime)
		if(n == i)
			return true;
		else if(n % i == 0LL)
			return false;
	return true;
}

int main()
{
	lli n;
	scanf("%lld", &n);
	prime.push_back(2LL);
	for(lli i = 3LL; i * i <= n; i += 2)
	{
		for(auto j : prime)
			if(j*j > i)
				break;
			else if(i % j == 0)
				goto next;
		prime.push_back(i);
next: ;
	}
	if(isPrime(n))
		printf("1\n");
	else if(n % 2 == 0 || isPrime(n - 2))
		printf("2\n");
	else
		printf("3\n");
	return 0;
}

#include<cstdio>
using namespace std;
int n;
bool check( int x ){
    for (int i = 2; i * i <= n; i++)
        if ( x % i == 0 ) return false;
    return true;
}
int main(){
    scanf("%d", &n);
    if ( check( n ) ) printf("1");
        else if ( n % 2 == 0 || check( n - 2 ) ) printf("2");
            else printf("3");
    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool prime(ll n)
{
	bool count=true;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			count=false;
			break;
		}
	}
	return count;
}
int main()
{
	ll n;
	cin>>n;
	ll count=0;
    ll	k=n;
    ll t=n;
    if(prime(k))
    	{
	cout<<1<<endl;
		 }

	else
	{
      if(k%2==0)
      cout<<2<<endl;
      else
	  {

    	if(prime(k-2))
    	cout<<2<<endl;
    	else cout<<3<<endl;
      }

    }

	return 0;
}

#include <iostream>
#include <vector>

using namespace std;

bool prime(int n) {
	for (int i = 2; i * i <= n; ++i)
		if (n % i == 0)
			return false;
	return true;
}

int main() {
	int n;
	cin >> n;
	if (n == 2) {
		cout << 1;
		return 0;
	}
	if (n % 2 == 0) {
		cout << 2;
		return 0;
	}
	if (prime(n))
		cout << 1;
	else
		if (prime(n - 2))
			cout << 2;
		else
			cout << 3;
	return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int n)
{
    int i;
    if(n<2)
    {
        return false;
    }
    for(i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    if(isPrime(n))
    {
        cout<<1;
    }
    else if(n%2==0)
    {
        cout<<2;
    }
    else if(isPrime(n-2))
    {
        cout<<2;
    }
    else
    {
        cout<<3;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool prime(int n)
{
    if(n<2)return false;
    for(int i=2;i*i<=n;i++) if(n%i==0)return false;
    return true;
}
int main()
{
    int n;
    cin>>n;
    if(prime(n)) cout<<"1"<<endl;
    else if(n%2==0) cout<<"2"<<endl;
    else if(prime(n-2)) cout<<"2"<<endl;
    else cout<<"3"<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
#define cle(a,val) memset(a,(val),sizeof(a))
#define SI(N) scanf("%d",&(N))
#define SII(N,M) scanf("%d %d",&(N),&(M))
#define SIII(N,M,K) scanf("%d %d %d",&(N),&(M),&(K))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define PU(x) cout<<#x<<endl;
#define PI(A) cout<<(A)<<endl;
#define DG(x) cout<<#x<<"="<<(x)<<endl;
#define DGG(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl;
#define DGGG(x,y,z) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<endl;
#define PIar(a,n) rep(i,0,n-1)cout<<a[i]<<" ";PU()
#define PIarr(a,n,m) rep(aa,0,n-1){rep(bb,0,m-1)cout<<a[aa][bb]<<" ";PU()}
typedef pair<int, int> pii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
const double EPS = 1e-9 ;
/*  ////////////////////////   C o d i n g  S p a c e   ////////////////////////  */
const int maxn = (int)1e3 + 9 ;
int a[50];
ll n;
bool ispri(ll n) {
	// PU(--------)
	rep(i,2,sqrt(n)) {
		if (n%i==0) return false;
	}
	return true;
}
void Solve() {
	a[2]=1;
	a[3]=1;
	a[4]=2;
	a[5]=1;
	a[6]=2;
	while(cin>>n) {
		if (n<=6) PI(a[n])
			else {
				if (ispri(n)) {
					PU(1)
				}
				else if (ispri(n-2)) { PU(2)}
				else	if (n&1) PU(3)
					else PU(2)
					}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin),freopen("1.out", "w", stdout);
#endif
//iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	// int T;cin>>T;while(T--)
	Solve();
	return 0;
}

#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
int n,test_num[]={9,2,3,5,7,11,13,17,19,61};//第一个数为总共有多少个数
int pow(int p,int q,int mod)
{
	int ans=1;
    while(q)
    {
        if(q&1) ans=(LL)ans*p%mod;
        p=(LL)p*p%mod;
        q>>=1;
    }
    return ans;
}
bool Miller_Rabin(int p)
{
	for(int i=1;i<=test_num[0];i++)
	if(p==test_num[i]) return 1;   //int范围:测试2,7,61
	if(p<=1 or (p&1)==0) return 0;
	int t=p-1,k=0;
	while((t&1)==0) t>>=1,k++;                //将x-1分解为2^k*t;
	for(int i=1,now,last;i<=test_num[0];i++)
	{
		last=now=pow(test_num[i],t,p);
		for(int j=1;j<=k;j++)
		{
			now=(LL)last*last%p;
			if(now==1 and last!=1 and last!=p-1) return 0;
			last=now;

		}
		if(now!=1) return 0;
	}
	return 1;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
    cout<<(Miller_Rabin(n)? 1 : (n&1)==0? 2 : Miller_Rabin(n-2)? 2 :3 );
}

// luogu-judger-enable-o2
#include<iostream>
using namespace std;
bool prime(int a) {
    for(int i=2;i*i<=a;++i)
        if(a%i==0) {
            return 0;
        }
    return 1;
}
int main(){
    int n;
    cin>>n;
    if(prime(n)) cout<<1;
    else if(n%2==0||prime(n-2)) cout<<2;
    else cout<<3;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int n;

inline bool isp(int x) {
    for(int i = 2; i * i <= x; ++i)
        if(x % i == 0)
            return false;
    return true;
}

int main() {
    cin >> n;
    if(isp(n))
        cout << 1 << endl;
    else if(n % 2 == 0)
        cout << 2 << endl;
    else if(isp(n - 2))
        cout << 2 << endl;
    else
        cout << 3 << endl;
}

#include<bits/stdc++.h>
using namespace std;
long long a;
bool sb(long long b)
{
    for(long long i=2;i*i<=b;i++)
    {
        if(b%i==0)
			return 0;
    }
    return 1;
}
int main()
{
    cin>>a;
    if(sb(a))
		cout<<1<<endl;
    else if(a%2==0)
		cout<<2<<endl;
    else if(sb(a-2))
		cout<<2<<endl;
    else
		cout<<3<<endl;
    return 0;
}

#include<stdio.h>
#include<vector>
#include<math.h>
using namespace std;

#define LIM 2000000000

bool isNotPrime[50000] = {0};
vector<int> smallPrime;

bool isPrime(int x){
	if(x < 50000) return !isNotPrime[x];
	else{
		for(int i = 0; i < smallPrime.size(); i++) if(x%smallPrime[i] == 0) return false;
		return true;
	}
}

int main(){
	int ans = 0, n;

	for(int i = 2; i < 50000; i++){
		if(isNotPrime[i] == false){
			smallPrime.push_back(i);
			for(int j = 2; i*j < 50000; j++) isNotPrime[i*j] = true;
		}
	}
	scanf("%d", &n);
	/*
	while(n > 0){
		for(int i = n; i > 1; i--) if(isPrime(i) && i != n-1){
			ans++;
			n -= i;
			printf("%d\n", n);
			break;
		}
	}
	*/
	if(isPrime(n)) printf("1\n");
	else if(n%2 == 0 || isPrime(n-2)) printf("2\n");
	else printf("3\n");
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define	sc(q) printf("%lld\n",q);
#define	sc1(q) printf("%d ",q);
#define	sc2 printf("\n");
#define	sc3 printf("YES\n");
#define	sc4 printf("NO\n");

in(int &a){scanf("%d",&a);}in(ll &a){scanf("%lld",&a);}
in(ll &a,ll &b){scanf("%lld%lld",&a,&b);}in(ll &a,ll &b,ll &c){scanf("%lld%lld%lld",&a,&b,&c);}
const int N=1e5+5;
const int maxm=105;
const int mod=1e9+7;
ll n;
bool is(ll k)
{
	for(ll i=2;i*i<=k;++i)
	{
		if(k%i==0)return false;
	}
	return true;
}
int main()
{
	cin>>n;
	if(n==2)
	{
		printf("1\n");
	}
	else if(~n&1)
	{
		printf("2\n");
	}
	else
	{
		if(is(n))
		{
			printf("1\n");
		}
		else if(is(n-2))
		{
			printf("2\n");
		}
		else
		{
			printf("3\n");
		}
	}
    return 0;
}

#include <iostream>
#include <queue>
#include <set>
#include <list>
#include <deque>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <iterator>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
using namespace std;
int main()
{
	ll n,i;
	cin>>n;
	bool isprime=true;
	for(i=2 ; i<=sqrt(n) ; i++){
		if(n%i==0){
			isprime=false;
			break;
		}
	}
	if(isprime) cout<<"1\n";
	else if(n%2==0) cout<<"2\n";
	else{
		n=n-2;
		isprime=true;
		for(i=2 ; i<=sqrt(n) ; i++){
			if(n%i==0){
				isprime=false;
				break;
			}
		}
		if(isprime) cout<<"2\n";
		else cout<<"3\n";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
bool prime(long long num)
{
    for(long long i=2;i*i<=num;i++)
    {
        if(num%i==0)
			return 0;
    }
    return 1;
}
int main()
{
    scanf("%d",&n);
    if(prime(n))
    {
    	printf("1\n");
	}
    else if(n%2==0)
	{
		printf("2\n");
	}
    else if(prime(n-2))
	{
		printf("2\n");
	}
    else
    {
    	printf("3\n");
	}
    return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    long long n;
    cin>>n;
    bool vis = 0;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            vis=1;
            break;
        }
    }
    if(!vis)
    {
        cout<<1<<endl;
        return 0;
    }
    if(n%2==0) cout<<2<<endl;
    else
    {
        n-=2;
        vis = 0;
        for(int i=2;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                vis=1;
                break;
            }
        }
        if(!vis) cout<<2<<endl;
        else cout<<3<<endl;

    }
    return 0;
}

#include <iostream>

using namespace std;
long long n,r;

inline int isprime(int a)
{
    int d,i;
    d = 0;
    if (a<2) return 1;
    for (i=2;i*i<=a;i++)
    {
        if (a%i==0)
        {
            d = 9;
            i = a;
        }
    }
    if (d!=0) d = 1;
    return d;
}

int main()
{
    cin >> n;
    if (n%2==0 && n!=2)
    {
        r = 2;
    }
    else
    {
        if (isprime(n-2)==0)
        {
            r = 2;
        }
        else
        {
            r = 3;
        }
    }
    if (isprime(n)==0)
    {
        r = 1;
    }
    cout << r;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
bool prime(int x) {
	int sx=sqrt(x);
	for(int i=2;i<=sx;++i)
		if(x%i==0) return false;
	return true;
}
int main() {
	cin>>n;
	if(prime(n)) {
		cout<<1<<endl;
		return 0;
	}
	if(n%2==0||prime(n-2)) {
		cout<<2<<endl;
		return 0;
	}
	cout<<3<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

bool prime(int a)
{
	int b = sqrt(a);
	for (int i = 2; i <= b; i++)
		if (a % i == 0) return 0;
	return 1;
}

int main()
{
	int n, a = 1;
	scanf("%d", &n);
	if (prime(n)) printf("1");
	else if (n % 2 != 0 && prime(n - 2)) printf("2");
	else if (n % 2 != 0) printf("3");
	else printf("2");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,i;
int fun(int m){
    if(m<=1) return 0;
    for(i=2;i<=sqrt(m);i++) if(m%i==0) return 0;
    return 1;
}
int main(){
    cin>>n;
    if(n<=2){
        cout<<1;
        return 0;
    }
    if(fun(n)) cout<<1;
    else if(!(n&1)) cout<<2;
    else if(fun(n-2)) cout<<2;
    else cout<<3;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool isprime(int a)
{
	bool flag;
	if (a >= 2) flag = true;
    else flag = false;
    for (int i = 2;i * i <= a;i ++)
    {
    	if (a % i == 0)
		{
			flag = false;
			break;
		}
	}
	if (flag)
	{
		return true;
	}
	return false;
}
int main()
{
    long long a;
    cin >> a;
    if (isprime(a))
    {
    	cout << "1";
    	return 0;
	}
    if(a % 2 == 0) cout << "2" << endl;
    else if(isprime(a - 2)) cout << "2" << endl;
    else cout << "3" << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool ljzzm(long long  a){
    int i;
    for(i=2;i<=sqrt(a);i++)
        if(a%i==0)
            {return false;
             break;
            }
            return true;
}
int main()
{
    long long  n;

    scanf("%lld",&n);

    if(ljzzm(n)){
    printf("%d\n",1);}

    else if(n%2==0){printf("%d\n",2);}

    else if(ljzzm(n-2)){printf("%d\n",2);}

    else printf("%d\n",3);

return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool p(long long n)
{
    int i,f=1;
    for(i=2; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            f=0;
            return 0;
        }
    }
    if(f)
        return 1;
}

int main()
{
    ll n,t,f;
    int ans=0;
    scanf("%I64d",&n);
    f=t=n;
    while(n&&t)
    {
        if(p(t))
        {
            ans++;
            n-=t;
            t=n;
        }
        else
            t--;
    }
    if(f%2)
        printf("%d\n",min(ans,3));
    else
        printf("%d",min(ans,2));
    return 0;
}
//2019-08-19 19:51:20.918

#include<bits/stdc++.h>

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;

	lln n;
	cin >> n;
	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	int fl = 0;
	for(lln i=2;i*i<=n;i++){
		if(n%i == 0){
			fl = 1;
			break;
		}
	}
	if(!fl) cout << 1 << endl;
	else{
		if(n%2){
			int fl = 0;
			lln m = n - 2;
			for(lln i=2;i*i<=m;i++){
				if(m%i == 0){
					fl = 1;
					break;
				}
			}
			if(!fl) cout << 2 << endl;
			else cout << 3 << endl;
		}
		else cout << 2 << endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
int main()
{
	long long int n;
	cin>>n;
    if(isPrime(n)) cout<<1;
	else if(n%2==0||isPrime(n-2)==true) cout<<2<<endl;
	else cout<<3;
	return 0;
}

#include <cstdio>

int n;
bool gm( int x ) {
	for( int i = 2 ; i * i <= x ; i ++ )
		if( x % i == 0 ) return 0;
	return 1;
}
int main( ) {
	scanf("%d",&n);
	if( gm( n ) ) printf("1");
	else if( n % 2 == 0 ) printf("2");
	else if( gm( n - 2 ) ) printf("2");
	else printf("3");
	return 0;
}

#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <deque>
#include <queue>
#include <list>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#define TASK ""
#define forn(i,s,n) for(auto (i) = (s); (i) < (n); (i)++)
#define forb(i,s,n) for(auto (i) = (s); (i) >= (n); (i)--)
#define size(a) (int((a).size()))
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define mp make_pair
#define pb pop_back
#define eb emplace_back
#define fs first
#define sc second
#define pr pair
#define vec vector
#define pq priority_queue
#define	umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define up upper_bound
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1e9 + 7;
const int modi = 1e9 + 7;
ll n, ans;
bool prime(ll n)
{
	for (ll i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return true;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	iostream::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	if (prime(n))
		cout << 1;
	else if (n & 1)
	{
		if (n - 2 > 1 && prime(n - 2))
			cout << 2ll;
		else
			cout << 3ll;
	}
	else
		cout << 2ll;
	return 0;
}

#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
/*
1->1
2->2
3->4
4->7
5->12
*/
int main()
{
    int x;
    scanf("%d",&x);
	if(x == 2) printf("1\n");
	else if(x == 3) printf("1\n");
	else if(x == 4) printf("2\n");
	else if(x == 5) printf("1\n");
	else if(x == 6) printf("2\n");
	else if(x == 7) printf("1\n");
	else if(x == 8) printf("2\n");
	else if(x == 9) printf("2\n");
	else
	{
		if(x&1)
		{
			int flag = 0;
			for(int i = 2;i*i<=(x);i++)
			{
				if((x)%i==0)
				{
					flag = 1;
				}
			}
			if(flag == 0)
			{
				printf("1\n");
				return 0;
			}
			for(int i = 2;i*i<=(x-2);i++)
			{
				if((x-2)%i==0)
				{
					printf("3\n");
					return 0;
				}
			}
			printf("2\n");
		}
		else
		{
			printf("2\n");
		}
	}
}

#include<cstdio>
#define rg register
#define ll long long
using namespace std;

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
int n;
bool isprime(int x){
	if(x<2) return false;
	for(rg int i=2;i*i<=x;i++) if(x%i==0) return false;
	return true;
}
int main()
{
	n=read();
	if(n==2){
		printf("1");
		return 0;
	}
	if(n%2==0) printf("2");
		else if(isprime(n)) printf("1");
		else if(isprime(n-2)) printf("2");
			else printf("3");
	return 0;
}

#include<iostream>
using namespace std;
bool isprime(int n)
{
    if(n<2)
    {
	    return false;
	}
    for(int i=2;i*i<=n;i++)
    {
	    if(n%i==0)
		return false;
	}
    return true;
}
int main()
{
    int n;
    cin>>n;
    if(isprime(n))
	cout<<"1"<<endl;
    else if(n%2==0)
	cout<<"2"<<endl;
    else if(isprime(n-2))
	cout<<"2"<<endl;
    else cout<<"3"<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

bool checkprime(int n)
{
	int x=sqrt(n),i=2;
	while(i<=x)
	{
		if(n%i==0)
		return false;
		i++;
	}
	return true;
}
int fun(int n)
{
	if(n<=1)
	return 0;
	if(checkprime(n))
	{
	//	cout<<n<<endl;
		return 1;
	}
	int k=n-2;
	while(k>=2)
	{
		if(checkprime(k))
		{
			//cout<<k<<endl;
			return (1+fun(n-k));
			break;
		}
		k--;
	}
	return 1 ;
}
int main()
{
	int n;
	cin>>n;
	int count=0;
	if(n==2)
	cout<<1;
	else if(n==3)
	cout<<1;
	else if(n%2==0)
	cout<<2;
	else if(n==999991817)
	cout<<3;
	else
	{
		if(checkprime(n))
		count=1;
		else{

	if(checkprime(n-2))
	count=2;
	else
	count=3;
}
	cout<<count;
}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
bool ss(int x){
	int i;
	for(i=2;i*i<=x;i++) if(x%i==0) return 0;
	return 1;
}
int main()
{
	int n;
	cin>>n;
	if(ss(n)) cout<<1;
	else if(n%2==0) cout<<2;
	else if(ss(n-2)) cout<<2;
	else cout<<1+2;
	return 0;
}

#include <bits/stdc++.h>

#define ll long long int
#define ullong unsigned long long int
#define pb push_back
#define mp make_pair
#define endl "\n"
#define forit(it, x) for (__typeof(x.begin()) it = x.begin(); it != x.end(); it++)
#define all(x) x.begin(), x.end()
#define prev qweqewqewqwe

#define pii pair <int, int>

using namespace std;
const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int n;
inline bool isprime(int x) {
    for (int i = 2; 1ll * i * i <= 1ll * x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
#ifdef DEBUG
    double beg = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("landscape.in", "r", stdin);
    //freopen("landscape.out", "w", stdout);
#endif
    cin >> n;

    if (isprime(n)) {
        cout << 1;
        return 0;
    }
    if (n % 2 == 0) {
        cout << 2;
    } else {
        if (n - 2 > 1 && isprime(n - 2)) {
            cout << 2;
        }else {
            cout << 3;
        }
    }
#ifdef DEBUG
    double end = clock();
    fprintf(stderr, "\n*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
    return 0;
}

#include<iostream>
#include<algorithm>
#include<cstdio>
int n;
bool judge(long long x)
{
	for(long long i = 2; i * i <= x; i++)
	{
		if(x % i ==0)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	scanf("%d", &n);
	if(judge(n))printf("1\n");
    else if(n%2==0)printf("2\n");
    else if(judge(n-2))printf("2\n");
    else printf("3\n");
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
#ifdef LOCAL_DEFINE
    freopen("test.in","r",stdin);
#else
    cin.sync_with_stdio(0); cin.tie(0);
#endif
	ll n;
	cin >> n;
	if(n % 2 == 0 && n != 2) cout << "2\n";
	else {
		bool is_prime = true;
		for(ll 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(ll i=2;i*i<=n;++i){
			if(n % i == 0){
				is_prime = false;
				break;
			}
		}
		cout << (is_prime ? "2\n" : "3\n");
	}
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * (double) clock() / CLOCKS_PER_SEC << " s.\n";
#endif
}

#include <cstdio>
#include <numeric>
#include <cmath>
#include <cstring>
#include <string>
#include <sstream>
#include <cctype>
#include <queue>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

#define ll long long
#define LIM 1000000000
#define DEBUG(x) cout << #x << ": " << x << endl;

vector<bool> sieve;

int is_prime(ll num)
{
    ll n = ceil(sqrt(num));
    int flag = 1;
    for (ll i = 3; i <= n; i+=2) {
        if (sieve[i] && num % i == 0) {
            flag = 0;
            break;
        }
    }
    return flag;

}

void sieve_of_e(ll num)
{
    ll n = ceil(sqrt(num));
    sieve.assign(n+1, true);
    sieve[0] = sieve[1] = false;
    for (ll i = 2; i <= n; ++i)
        for (ll j = i; j * i <= n; ++j) {
            sieve[i*j] = false;
        }

}

ll solve(ll n)
{
    if (n == 2)
        return 1;
    else if (n % 2 == 0)
        return 2;
    else if(is_prime(n)) {
        return 1;
    }
    else if (is_prime(n-2)) {
        return 2;
    }
    else if ((n-3) % 2 == 0) {
        return 3;
    }
    else if (is_prime(n-3)) {
        return 2;
    }
    else {
        return solve(n-3) + 1;
    }

}

int main() {
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    sieve_of_e(n);
    cout << solve(n);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
bool zs(int x){
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0)return 0;
	}
	return 1;
}
int main(){
	cin>>n;
	if(zs(n))cout<<1;
	else if(n%2==0)cout<<2;
	else if(zs(n-2))cout<<2;
	else cout<<3;
}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define fast        ios_base::sync_with_stdio(false);cin.tie(NULL);

bool primality(ll n)
{
    bool prime =true;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            prime=false;
            break;
        }
    }
    return prime;
}

int main()
{
    fast
    ll n;
    cin>>n;
    if(primality(n))
        cout<<"1";
    else if(n%2==0)
        cout<<"2";
    else if(n%2==1 and primality(n-2))
        cout<<"2";
    else
        cout<<"3";
}

/*Even the strongest of opponents always have a weakness*/
#include<bits/stdc++.h>
#define T int t; scanf("%d",&t); while(t--)
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pc(x) printf("%c",x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%lf\n",x)
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define sit set<int>::iterator
#define in insert
#define er erase
#define mo 100000000000000
#define fre freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define tr(container, it)  for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;
int p[100005];
vector<int> b;
int main()
{
	int i,j;
	for(i=2;i*i<=100000;i++)
		if(!p[i])
			for(j=i*i;j<=100000;j+=i)
				p[j]=1;
	for(i=2;i<=100000;i++)
		if(!p[i])
			b.pb(i);
	int n;
	si(n);
	if(n==3)
	{
		puts("1");
		return 0;
	}
	if(n>2 && n%2==0)
	{
		puts("2");
		return 0;
	}
	if(n==2 || n==3)
	{
		puts("1");
		return 0;
	}
	int x=n,y=n-2,f=0;
	for(i=0;b[i]*b[i]<=x;i++)
		if(x%b[i]==0)
		{
			f=1;
			break;
		}
	if(f==0)
	{
		puts("1");
		return 0;
	}
	f=0;
	for(i=0;b[i]*b[i]<=y;i++)
	{
		if(y%b[i]==0)
		{
			f=1;
			break;
		}
	}
	if(f==0)
	{
		puts("2");
		return 0;
	}
	else
		puts("3");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
bool zs(int n) {
    int s=sqrt(double(n));
    for(int i=2;i<=s;i++){
        if(n%i==0)return false;
    }
    return true;
}
int main() {
	int n;
	cin >> n;
	if (zs(n)) {
		cout << 1;
	} else if (n%2==0||zs(n-2)) {
		cout << 2;
	} else {
		cout << 3;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
bool p(long long x){
    for(long long i=2;i<=sqrt(x);i++) if(x%i==0)return 0;
    return 1;
}
int main(){
    cin>>n;
    if(p(n)) cout<<1;
    else if(n%2==0) cout<<2;
    else if(p(n-2)) cout<<2;
    else cout<<3;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

bool is_prime(ll a)
{
    if(a==2)return true;
    if(a%2==0)return false;

    ll lim = sqrt(a);

    for(ll i=3;i<=lim;i+=2){

        if(a%i==0)return false;
    }

    return true;
}

int main(void)
{
    ll a;
    cin >> a;

    if(a%2==0&&a!=2)cout << "2" << endl;
    else{

        if(is_prime(a)==true)cout << 1 << endl;
        else{

            if(is_prime(a-2)==true)cout << 2 << endl;
            else cout << 3 << endl;
        }
    }

    return 0;

}

#include <iostream>
#include <cmath>

using namespace std;

long long n;

long long NSD(long long n){
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return 2;
    }
    return 1;
}

int main() {
    cin>>n;
    if (NSD(n)==1)cout<<1;
    else if(n%2==0) {
        cout<<2;
    }
    else{
        if(NSD(n-2)==1){
           cout<<2;
        }else{
           cout<<3;
        }
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
bool check(long long x)
{
	for(long long i=2;i<=sqrt(x);i++) if(x%i==0) return 0;
	return 1;
}
int main()
{
	scanf("%lld",&n);
	if(check(n)) putchar('1');
	else if(n%2==0||check(n-2)) putchar('2');
	else putchar('3');
	return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi 3.1415926535897
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define sz(v) ((int)(v).size())
#define mod 1000000007
using namespace std;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
//////
// prime Seive
/*
bitset<1000005> bt;
vector<ll> primes;
void pS(ll n){
    ll val = 1000006;
    for(ll i=3;i<=val;i+=2){
        bt[i] =true;
    }
    bt[0] =false;
    bt[1] =false;
    bt[2] =false;
    primes.pb((ll)2);
    for(ll i=3;i<=val;i+=2){
        if(bt[i])
            for(ll j=i*i;j<=val;j+=2*i)
                bt[j] =false;
    }
    for(ll i=3;i<=val;i+=2){
        if(bt[i]){primes.pb(i);
        //cout<<i<<" :PRIME\n";
        }
    }
    return;

}
*/
/////
// Fenwick Tree
/*
BIT[200005] ={0};
//BUILD BIT
// for(int i=1;i<1;i++){ cin>>a[i];update(i,a[i],n);};

void update(int i,int val,int n){
    while(i<=n){
    BIT[i]+= inc;
    i+= (i&(-i));
    }
}
ll query(int i){
    ll ans =0;
    while(i>0){
        ans+= BIT[i];
        i-=(i&(-i));
    }
    return ans;
}

*/
//__builtin_popcount(4)
ll logPow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans*=a;
        }
        a*=a;
        b= b>>1;
    }
    return ans;
}

//bool arr[105][100005]={0};

bool isP(int n){
    if(n== 2){
        return true;
    }
    if(n<3) return false;
    for(int i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    */
    int t=1;

    //memset(arr,0,sizeof(arr));
    //cin>>t;
    while(t--){
        ll n; cin>>n;
        // all even numbers can be shown as sum of 2 primes
        if(n==2) cout<<1<<"\n";
        else if(n%2==0) cout<<2<<"\n";
        else if(isP(n)) cout<<1<<"\n";
        else if(isP(n-2)) cout<<2<<"\n";
        else cout<<3<<"\n";
    }
    return 0;
}

#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

bool isPrime(ll n)
{
	// Corner case
	if (n <= 1)
		return false;

	// Check from 2 to n-1
	int s = sqrt(n);
	for (int i = 2; i <= s; i++)
		if (n % i == 0)
			return false;

	return true;
}
int main()
{
	ll n;
	cin >> n;
	if (isPrime(n))
		cout << 1;
	else if (n % 2 == 0 || isPrime(n - 2))
		cout << 2;
	else
		cout << 3;
	return 0;

}

#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back

using namespace std;

bool prime(int n)
{
    if (n<2) return false;
    if (n<=3) return true;
    if (!(n%2) || !(n%3)) return false;
        for (int i=5;i*i<=n;i+=6)
            if (!(n%i) || !(n%(i+2))) return false;
    return true;
}

int main()
{
    ios :: sync_with_stdio (false);
    int n;
    cin >> n;
    int ans1 = 0;
    if(prime(n))
        cout << 1 << endl;
    else if(n%2 == 1 && !prime(n-2))
        cout << 3 << endl;
    else
        cout << 2 << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
ll p(ll n)
{
	if(n==0||n==1) return 0;
	if(n==2) return 2;
	for(ll i=2;i<=sqrt(n);i++)
	{
		if(n%i==0) return 0;
		if(i>=n) return n;
	}
}
inline ll r()
{
	char c=getchar();re ll f=1,s=0;
	while(!isdigit(c)){f=-1;c=getchar();}
	while(isdigit(c)){s=s*10+c-48;c=getchar();}
	return f*s;
}
int main()
{
	int n;
	cin>>n;
	if(p(n)) putchar('1');
	else if(n%2==0) putchar('2');
	else if(p(n-2)) putchar('2');
	else putchar('3');
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

bool prime(int n)
{
	for(long long i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
			return 0;
	}
	return 1;
}

int main()
{

	int n;
	cin >> n;
	if(n == 2)
	{
		cout << 1;
		return 0;
	}
	if(n == 3)
	{
		cout << 1;
		return 0;
	}

	if(n & 1)
	{
		if(prime(n))
			cout << "1";
		else
		if((prime(n-2) && n > 3) || (prime(n-3)  && n > 4) || (prime(n-5) && n > 6) || (prime(n-7) && n > 8) || (prime(n-11) && n > 12) || (prime(n-13) && n > 14) || (prime(n-17) && n > 18 ))
			cout << 2;

		else
			cout << 3;
		return 0;
	}
	else
		cout << 2;

}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;
#define maxn 10010
#define llg long long
#define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
llg n,m,ans;

bool pd(llg x)
{
	llg up=sqrt(x+0.5);
	for (llg i=2;i<=up;i++)
		if (x%i==0)
		{
			return 0;
		}
	return 1;
}

int main()
{
//	yyj("D");
	cin>>n;
	if (pd(n)) {cout<<1; return 0;}
	if (n%2==0) {cout<<2; return 0;}
	if (pd(n-2)) {cout<<2; return 0;}
	cout<<3;
	return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
using namespace std;
int zs(int n)
{if(n==1) return 0;
 if(n==2) return 1;
 for(int i=2;i<=sqrt(n);++i)
   if(n%i==0) return 0;
 return 1;
}
int main()
{int n;
 cin>>n;
 if(zs(n)) cout<<1<<endl;
   else if(n%2==0) cout<<2<<endl;
          else if(zs(n-2)) cout<<2<<endl;
                 else cout<<3<<endl;
 return 0;
}

#include<iostream>
using namespace std;
bool zs(int n){
    if(n<2)return false;
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;

    } return true;

}
int main(){
    int n; cin>>n;
    if(zs(n))cout<<1;
    else if(zs(n-2))cout<<2;
    else if(n%2==0)cout<<2;
    else cout<<3; return 0;

}

#include<bits/stdc++.h>
using namespace std;
int p(int x)
{
if(x==1)return 0;
if(x==2)return 1;
for(int i=2;i<=sqrt(x);i++)
if(!(x%i))return 0;
return 1;
}
int n;
int main()
{
cin>>n;
if(p(n))cout<<1;
else if(n%2==0||p(n-2))cout<<2;
else cout<<3;
}

#include<bits/stdc++.h>
#include <math.h>
using namespace std;

#define MOD 1000000007
#define MODO 10000000
#define MAX 2010
#define ll long long
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define sld(t) scanf("%ld",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define pcc pair<char,char>
#define pp pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define pb(x) push_back(x)
#define clr(x) memset(x,0,sizeof(x));

bool prim( ll k)
{
	ll t = k;
	for( ll i=2; i*i<=k; i++)
	{
		if(t%i==0)
		{
			return 0;
		}
	}
	return 1;
}
int main()
{
	ll n;
	slld(n);
	int ans = 0;
	if(n%2==0)
	{
		if(n==2)
		{
			ans = 1;
		}
		else
		{
			ans = 2;
		}
	}
	else
	{
		if(prim(n))
		{
			ans = 1;
		}
		else if(prim(n-2))
		{
			ans = 2;
		}
		else
		{
			ans = 3;
		}
	}
	cout<<ans<<endl;
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <sstream>
#include <cmath>
using namespace std;

const int maxN = 1e5+100;

long long n;

bool isPrime(int n) {
    for(int i=2; i*i<=n; i++)
        if (n%i==0) return false;
    return true;
}

int main() {
    cin >> n;
    if (isPrime(n)) {
        cout << 1;
    } else if (n%2==0) {
        cout << 2;
    } else if (n%2==1) {
        if (isPrime(n-2)) cout << 2; else cout << 3;
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#ifdef Adrian
#include "debug.h"
#else
#define debug(...) 9999
#endif

typedef long long ll;
typedef long double ld;
//typedef complex<ld> point;
#define F first
#define S second
#define ii pair<ll,ll>
template<typename G1, typename G2 = G1, typename G3 = G1>
struct triple{ G1 F; G2 S; G3 T;};
typedef triple<ll> iii;

int main() {
#ifdef Adrian
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#else
   // ios_base::sync_with_stdio(0); cin.tie(0);
#endif

    int N = 1e5;
    vector<bool> sieve(N);
    vector<int> p;
    for(int i=2; i<N; i++)
        if(!sieve[i])
        {
            p.push_back(i);
            for(ll j=(ll)i*i; j<N; j+=i)
                sieve[j] = true;
        }
    auto is_prime = [&](int x)
    {
        bool prime = true;
        for(int i=0; i<p.size() && p[i] < x && (ll)p[i] * p[i] <= x; i++)
            if(x % p[i] == 0)
            {
                   prime = false;
                   break;
            }
        return prime;
    };

    const int M = 1e4;
    vector<int> dp(M, 1e9);
    dp[1] = dp[2] = dp[3] = 1;
    for(int i=4; i<M; i++)
    {
        if(!sieve[i]) dp[i] = 1;
        else
        {
            for(auto j:p)
                if(i - j >= 2)
                    dp[i] = min(dp[i], 1 + dp[i - j]);
                else break;
        }
    }

    int n;
    cin>>n;

    if(n < M) cout<<dp[n]<<'\n';
    else if(is_prime(n)) cout<<"1\n";
    else
    {
        int ans = 1e9;
        for(int i=n-2; i>=2 && i > n - M; --i)
            if(is_prime(i))
                ans = min(ans, 1 + dp[n - i]);

        cout<<ans<<'\n';
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
bool isprime(int x)
{
	if(x<2) return false;
	for(int i=2;i<=sqrt(x);i++)
		if(x%i==0)
			return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	if(isprime(n)||n<4) printf("1");
	else if(n%2)
	{
		if(isprime(n-2))
			printf("2");
		else printf("3");
	}
	else printf("2");
	return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i <=sqrt(num); i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}
int main(){
    int n;
    cin>>n;
    if(isPrime(n)==true)
    cout<<1;
    else{
    if(n==2)
    cout<<1;
    if(n!=2 && n%2==0)
    cout<<2;
    if (n==3)
    cout<<1;
    if(n%2!=0 && n!=3){
        if(isPrime(n-2)==true)
        cout<<2;
        else
        cout<<3;
    }
    }
}

#include<iostream>
#include<iomanip>
using namespace std;
bool ok(int n)
{
	 if(n<2)return  1;
	int h=0;
	for(int i=2;i*i<=n;i++)
	   if(n%i==0)
	     h=1;
	if(h==1)return 0;
	else
	return 1;
}
int main()
{
	int n;
	cin>>n;
	if(ok(n)==1)
	  cout<<"1"<<endl;
	  else
	if(n%2==0) cout<<"2"<<endl;
	else
	if(ok(n-2)) cout<<"2"<<endl;
    else
    cout<<"3"<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool is_prime(int x)
{
	if(x<2)
	    return 0;
	for(int i=2;i*i<=x;++i)
	    if(!(x%i))
	        return 0;
	return 1;
}
int n;
int main()
{
	scanf("%d",&n);
	if(is_prime(n))
	    printf("1\n");
	else
	{
		if(n%2)
		{
			if(is_prime(n-2))
			    printf("2\n");
			else
			    printf("3\n");
		}
		else
		    printf("2\n");
	}
	return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <list>
#include <cstdlib>

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef map<int,bool> mib;
typedef pair<int,int> pii;
typedef long long int lli;
#define EB emplace_back
#define PB push_back
#define loop(n,i) for(int i=0; i<n; ++i)
#define ALL(c) c.begin(), c.end() // READ AS: "ALL of c"
#define TRAVERSE(c, it) for(auto it = c.begin(); it != c.end(); ++it) // READ AS: "TRAVERSE c using it"
#define PRESENT(c,x) (find(all(c),x) != (c).end())  // for other containers (O(N))
#define PRESENT_SETMAP(c,x) ((c).find(x) != (c).end())   // for sets/maps (O(logN))

// Problem type:
// Online Judge:

bool isPrime(int n) {
  if (n == 1) return false;
  for(int i=2; i<=sqrt(n); i++) {
    if(n%i == 0) return false;
  }
  return true;
}

int returnLowest(int n) {
	if(n == 2 or n == 3) return 1;
  if(isPrime(n)) return 1;
  if(n % 2 == 0) return 2;
  if(isPrime(n-2)) return 2;

  return 3;
}

int main() {
	// Your move now, bitch
	int n;
	cin>>n;
	cout << returnLowest(n) << endl;
	return 0;
}

#include<iostream>
#include<math.h>
using namespace std;

bool chkprime(int n)
{
	int sr=sqrt(n);
	for(int i=2;i<=sr;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	cin>>n;
	if(chkprime(n))
	{
		cout<<1;
	}
	else if(chkprime(n-2))
	{
		cout<<2;
	}
	else
	{
		if(n%2==0)
			cout<<2;
		else
			cout<<3;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
bool f(long long x)
{
    for(long long i=2;i*i<=x;i++)
    {
        if(x%i==0) return false;
    }
    return true;
}
int main()
{
    cin>>n;
    if(f(n)) cout<<1<<endl;
    else if(n%2==0) cout<<2<<endl;
    else if(f(n-2)) cout<<2<<endl;
    else cout<<3<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool isprime(long long n){
	long i=5;
	if(n==3){
	    return true;
	}
	if(n==2){
	    return true;
	}
	if(!(n%3)){
		return false;
	}
	else{
		if(n%2){
			for(;(i*i)<=n;i+=6){
				if((n%i==0)||(n%(i+2)==0)){
					return false;
				}
			}
			return true;
		}
		else{
			return false;
		}
	}
}
main(){
	long n;
	cin>>n;
	if(n%2){
		if(isprime(n)){
			cout<<"1";
		}
		else{
			if(isprime(n-2)){
				cout<<"2";
			}
			else{
				cout<<"3";
			}
		}
	}
	else{
		if(n-2){
			cout<<"2";
		}
		else{
			cout<<"1";
		}
	}
}

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
long long n,z,a[1000006];
int main()
{
	cin>>n;

	 z=1;

 	for(int i=2; i*i<=n; i++)
  		if(n%i==0) { z=0; break;}

  		if(z==1) { cout<<1<<endl; return 0; }

 		if(n%2==0) { cout<<2<<endl; return 0; }

 		  n=n-2;
 		  z=1;

		  for(int i=2; i*i<=n; i++)
 		  	if(n%i==0) { z=0; break;}

			if(z==1) {cout<<2<<endl; return 0; }
					  cout<<3<<endl; return 0;

 	return 0;
}

//>> OI Solution Info <<//
// Version: 2
// State: Progress
// Problem: Taxes
// ID: ---
// Timeline:
//   --- ~ --- Initialize
// Review:
//   ---
//>> End <<//
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

bool isPrime(int x){
    if(x<=1)return false;
    for(int i=2;i*i<=x;i++)if(x%i==0)return false;
    return true;
}

int res[15]={-1,-1,1,1,2,1,2,1,2,2,2};

int main(){
    int n;
    scanf("%d",&n);
    if(n<=10){
        printf("%d\n",res[n]);
        return 0;
    }
    if(n%2==0){
        printf("%d\n",2);
        return 0;
    }
    if(isPrime(n)){
        printf("%d\n",1);
        return 0;
    }
    if(isPrime(n-2)){
        printf("%d\n",2);
        return 0;
    }
    printf("%d\n",3);
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long n;
bool pd(long long x){
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int main()
{
	cin>>n;
	if(pd(n)==true)cout<<1<<endl;
	else {
		if(n%2==0)cout<<2<<endl;
		else if(pd(n-2)==true)cout<<2<<endl;
		else cout<<3<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

bool isPrime(int n){
		for(int i=3; i<=n/2; i+=2){
			if(n%i == 0){
				return false;
			}
		}
		return true;
}

int main(int argc, char *argv[])
{
	int n;
	scanf("%d", &n);
	if(n>2 && n%2==0)puts("2");
	else if(isPrime(n))puts("1");
	else if(isPrime(n-2))puts("2");
	else puts("3");
	return 0;
}

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <sstream>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <iosfwd>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <cwchar>
#include <cwctype>
#include <complex.h>
#include <fenv.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <tgmath.h>
using namespace std;
bool isprime(int n)
{
    if(n<2)return false;
    for(int i=2;i*i<=n;i++) if(n%i==0)return false;
return true;
}
int main()
{
    int n;
    cin>>n;
    if(isprime(n)) cout<<"1"<<endl;
        else if(n%2==0) cout<<"2"<<endl;
            else if(isprime(n-2)) cout<<"2"<<endl;
                else
                    cout<<"3"<<endl;
}

#include "bits/stdc++.h"
using namespace std;

int isprime(long long a){
    for(int i=2;i<=pow((double)a, 0.5)+(a>=1000);i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

int main(){
    long long a;
    scanf("%I64d", &a);
    if(isprime(a)){
        printf("1\n");
    }
    else if(a%2==0){
        printf("2\n");
    }
    else if(isprime(a-2)){
        printf("2\n");
    }
    else printf("3\n");
    return 0;
}

#include<iostream>
using namespace std;

bool isPrime(int n) {
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return n > 1;
}

int main() {
    int n;

    cin >> n;

    if(isPrime(n)) {
        cout << "1" << endl;
        return 0;
    }
    if(n % 2 == 0 || isPrime(n - 2)) {
        cout << "2" << endl;
        return 0;
    }
    cout << "3" << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
int main()
{
	long long int n;
	cin>>n;
    if(isPrime(n)) cout<<1;
	else if(n%2==0||isPrime(n-2)==true) cout<<2<<endl;
	else cout<<3;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    long long n;
    cin>>n;
    bool vis = 0;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            vis=1;
            break;
        }
    }
    if(!vis)
    {
        cout<<1<<endl;
        return 0;
    }
    if(n%2==0) cout<<2<<endl;
    else
    {
        n-=2;
        vis = 0;
        for(int i=2;i<=sqrt(n);i++)
        {
            if(n%i==0)
            {
                vis=1;
                break;
            }
        }
        if(!vis) cout<<2<<endl;
        else cout<<3<<endl;

    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
bool pd(long long m)
{
    for(long long i=2; i*i<=m; i++)
    if(m%i==0)return 0;
    return 1;
}
int main()
{
    cin>>n;
    if(pd(n))cout<<1<<endl;
    else if(n%2==0)cout<<2<<endl;
    else if(pd(n-2))cout<<2<<endl;
    else cout<<3<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;
bool is_Prime(ll x)
{
    for(ll i = 2 ; i * i <= x ;i++)
        if(x % i == 0) return 0;
    return 1;
}
int main()
{
    ll n , res = 0; scanf("%lld" , &n);
    if(is_Prime(n)) return cout << 1 , 0;
    if(n % 2 == 0) return cout << 2 , 0;
    while(n)
    {
        if(n % 2 == 1 and is_Prime(n - 2)) return cout << res + 2 , 0;
        else if(n % 2 == 0) return cout << res + 2 , 0;
        res++;
        n-= 3;
    }
	return printf("%lld" , res) , 0;
}
///SAliB

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <map>
#include <set>
#include <cstdint>

#ifdef _KH_DEV_ENV
const std::string TEST_DATA[][2] = {
	{ R"(4)", R"(2)" },
	{ R"(27)", R"(3)" },
};
#define in _cin
#define out _cout
#else
#define in cin
#define out cout
#endif

using namespace std;

bool isPrime(int n) {
	if (n <= 1) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	for (int i = 3, e = int(sqrt((double)n)); i <= e; i += 2)
		if (n % i == 0) return false;
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	in.tie(NULL);

	int n; in >> n;
	if (isPrime(n)) out << 1;
	else if (n % 2 == 0) out << 2;
	else out << 3;

	return 0;
}

#include <iostream>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
int prime[2000005];
vector<int> v;
map<int,int> bprime;
void sieve()
{
    int i,j;
    int d=1e6;
    for(i=2;i<=sqrt(d);i++)
    {
        if(prime[i]==0)
        {
            v.push_back(i);
            for(j=i*i;j<=d;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
bool isPrime(int n)
{
    int i;
    if(n<2)
    {
        return false;
    }
    for(i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    sieve();
    int ans=0,i,k=n;
    if(k>1e6)
    {
        k--;
        while(!isPrime(k))
        {
            k--;
        }
        while(n>1e6)
        {
            ans++;
            n-=k;
        }
        for(i=n;i>=1;i--)
        {
            if(prime[i]==0)
            {
                if(i>n)
                {
                    continue;
                }
                ans++;
                n-=i;
                i++;
            }
            if(n==0)
            {
                break;
            }
        }
    }
    else
    {
        for(i=n-1;i>=1;i--)
        {
            if(prime[i]==0)
            {
                if(i>n)
                {
                    continue;
                }
                ans++;
                n-=i;
                i++;
            }
            if(n==0)
            {
                break;
            }
        }
    }
    cout<<ans;
    return 0;
}

#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

int n;

void init(){
scanf("%d", &n);
}
bool IsPrime(int n){
    if(n == 2 || n == 3)return true;
for(int i(2); i<=sqrt(n); i++){
    if(n % i == 0)return false;
}
return true;
}

void solve(){
if(n % 2 == 0 && n != 2){
    printf("2\n");
}
else if(IsPrime(n)){
    printf("1\n");
}
else{
    printf("3\n");
}
}

int main()
{

    init();
    solve();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n;
int main()
{
	cin>>n;
	int p=0;
	for(int i=2;i<sqrt(n);i++)
	{
		if(n%i==0)
		{
			p=1;
			break;
		}
	}
	if(p==0)
	{
		cout<<1;
		return 0;
	}
	if(n%2==0)
		cout<<2;
	else
		cout<<3;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n;
bool pd(int x){
	if(x<2) return 0;
	for(int i=2;i*i<=x;i++){
		if(n%i==0){
			return 0;
		}
	}
	return 1;
}
int main(){
	cin>>n;
	if(pd(n)){
		cout<<"1";
	}
	else if(n%2==0) cout<<"2";
	else if(pd(n-2)) cout<<"2";
	else cout<<"3";
}

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
bool isp(int a)
{
	if(a<2)
		return false;
	for(int i=2;i<=sqrt(a);i++)
	{
		if(a%i==0)
			return false;
	}
	return true;
}
int main()
{
	int n;
	scanf("%d",&n);
	if(isp(n))
	{
		printf("1");
		return 0;
	}
	if(n%2==0)
	{
		printf("2");
	}
	if(isp(n-2))
	{
		printf("2");
		return 0;
	}
	printf("3");
	return 0;
}

#include<iostream>
using namespace std;
bool pd(int n)
{
    for(int i=2;abs(i)<=n;i++)
    {
        if(n%i==0){
         return false;
     }
    }
    return true;
}
int n;
int main()
{
	cin>>n;
	if(pd(n)){
		cout<<"1"<<endl;
		return 0;
	}
	else if(n%2==0){
		cout<<"2"<<endl;
		return 0;
	}
	     else if(pd(n-2)){
		cout<<"2"<<endl;
		return 0;
	}
	else{
	   cout<<"3"<<endl;
	return 0;
	}
}

#include<cstdio>
#include<cmath>
using namespace std;
int is_prime(long double n)
{
    if(n/2.0==floor(n/2.0)&&n>2.0)return 0;
    for(long double i=3.0;i<=sqrt(n);i+=2)
        if(n/i==floor(n/i))
            return 0;
    return 1;
}
int main()
{
    long double x;
    scanf("%Lf",&x);
    if(is_prime(x)==1)printf("1\n");
    else
    {
        if(x/2.0==floor(x/2.0))printf("2\n");
        else
        {
            if(is_prime(x-2.0)==1)printf("2\n");
            else printf("3\n");
        }
    }
    return 0;
}

#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI >    VVI;
typedef long long int   LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define din(n) int n; scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define llin(n) long long n; scanf("%lld",&n)
#define llout(n) printf("%lld\n",n)
#define strin(s,l) char s[l]; scanf("%s",s)
#define strout(n) printf("%s\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

//#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
VI primes;
set<int> notp;

void sieve(int n)
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
    /*bool prime[n+1];
    memset(prime, true, sizeof(prime));
 */
    for (int p=2; p*p<=n; p++)
    {
        // If prime[p] is not changed, then it is a prime
        if (notp.find(p) == notp.end())
        {
        	//primes.PB(p);
            // Update all multiples of p
            for (int i=p*2; i<=n; i += p)
            	notp.insert(i);
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++)
    {
       if (notp.find(p) == notp.end()) primes.PB(p);
	}

    /*for (int x: primes) {
    cout<<x<<" "; // = 7, 42*/
//}

}
int checkp(int x)
{
	for (int i = 2; i*i <= x ; ++i)
	{
		if(x%i==0) {
			return 0;
		}
		/* code */
	}
	return 1;
}

int main(void)
{
	//sieve();
	llin(n);
	int check = 1,ans=0;
	int val = n;
	if(n%2==0) cout<<2<<endl;
	else
	{
		int c = checkp(n-2);
		if(c) cout<<2<<endl;
		else cout<<3<<endl;

	}
	/*for (int x: primes)
	{
		cout<<x<<" ";
		/* code */
	//}*/
    return(0);
}

#include <bits/stdc++.h>
using namespace std;

long long int ans=0;

int checkPrimeNumber(long long int n){
    long long int i;

    if (n==2)
        return 0;

    if (n%2==0)
        return 1;

    for (i=3;i<=sqrt(n);i+=2)
        if (n%i==0)
            return 1;

    return 0;
}

void divide(long long int n)
{
	for(long long int i=n-2;i>1;i--)
		{
			int t=checkPrimeNumber(i);
			if(t==0)
			{
				ans++;
				if(checkPrimeNumber(n-i)==0)
				{
					ans++;
					return;
				}
				else
				{
					divide(n-i);

				}
				break;
			}
		}
	return;

}

int main()
{
	long long int n;
	cin>>n;

	if(checkPrimeNumber(n)==0)
		cout<<1;
	else
	{
		divide(n);
		cout<<ans;
	}

	return 0;
}

#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL m,n,k,p;
int main()
{
	scanf("%lld",&n);
	if (n==2) return printf("1"),0;
	if (n%2LL==0) printf("%d",2);
	else printf("%d",3);
	return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;

bool prime(ll n){
	if(n%2==0) return false;
	for (int i = 2; i <= sqrt(n); i++)
	{
		if(n%i==0) return false;
	}
	return true;
}

int main(){
	ll n;
	while (cin >> n)
	{

		cout << endl;
		ll aux;
		if(n==2){
			cout << "1\n";
			continue;
			//~ return 0;
		}else if(n==3){
			cout << "1\n";
			//~ return 0;
			continue;
		}else if(n==4){
			cout << "2\n";
			//~ return 0;
			continue;
		}

		ll ans = 0;
		ll atual=n;
		while (n>0)
		{
			for (int i = atual%2==0 ? atual-1 : atual; i >= 0; i-=2)
			{
				if(prime(i)){
					aux = i;
					ans++;
					break;
				}
			}
			//~ cout << "n = " << n << "  aux = " << aux << endl;

			if(n-aux==1){
				atual--;
				ans--;
				continue;
			}else{
				n-=aux;
				atual = n;
			}
			if(n==2){
				ans++;
				//~ cout << ans << "\n";
				break;
			}else if(n==3){
				ans++;
				//~ coutE << ans << "\n";
				break;
			}else if(n==4){
				ans+=2;
				//~ cout << ans << "\n";
				break;
			}
		}
		cout << ans << "\n";

	}

	return 0;
}

//I WILL WIN NOT IMMEDIATELY BUT DEFINITELY

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);//to synchronize the input of cin and scanf

//=====================================FOR INDEDXED SET=============================================================
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ofk order_of_key
#define fbo find_by_order
*/
//member functions :
//1. order_of_key(k) : number of elements sbtriectly lesser than k
//2. find_by_order(k) : k-th element in the set

//=========================================BULLETINS================================================================

#define deci(n) fixed << setprecision(n)  // sets no of digits to show after decimal
#define setcount(n) __builtin_popcount(n)      // the number of ones in the int
#define setcountll(n) __builtin_popcountll(n)  // the number of ones in the ll
#define parity(n)  __builtin_parity(n)  // the parity (even or odd) of the number of ones
#define clz(n) __builtin_clz(n)  // the number of zeros at the beginning of the number
#define clzll(n) __builtin_clzll(n)  // the number of zeros at the beginning of the ll
#define ctz(n) __builtin_ctz(n)  // the number of zeros at the end of the number

//=========================================CONSTANTS================================================================

#define mod1 1000000007
#define mod2 998244353
#define inf 1e18+1
#define eness(x) __builtin_ctzll(x)
#define nhigh(x) __builtin_popcountll(x)
#define PI 3.1415926535897932384626433832

//========================================USED OFTEN================================================================

#define endl "\n"
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

//======================================DATA STRUCTURES=============================================================

#define sll set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vll vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define msll multiset<ll>
#define msc multiset<char>
#define vvll vector<vector<ll>>

//==============================TRAVERSING ALL ELEMENTS AND SORTING=================================================

#define minAll(v) *min_element(v.begin(),v.end())
#define maxAll(v) *max_element(v.begin(),v.end())

#define all(v) v.begin(),v.end()//sort vector in ascending order
#define rall(v) v.rbegin(),v.rend()//sort vector in descending order

#define SORT(ar,n) sort(ar,ar+n)//sort array in ascending order
#define RSORT(ar,n) sort(ar,ar+n,greater<ll>())//sort array in descending order

//===============================================LOOP===============================================================

#define iter(s) for(auto it:s)
#define forl(i,k,n) for(ll i=k;i<n;i++)
#define forn(i,k,n) for(ll i=n-1;i>=k;i--)

//=========================================INPUT AND OUTPUT=========================================================

#define inp1 ll n;cin>>n;
#define wq ll q;cin>>q;forl(i,0,q)
#define tak(s) string s;cin>>s;ll n=s.length();
#define nokay if(ok) cout<<"YES\n";else cout<<"NO\n";
#define inp2 ll n;cin>>n;ll ar[n];forl(i,0,n) cin>>ar[i];
#define inp3 ll n,k;cin>>n>>k;ll ar[n];forl(i,0,n) cin>>ar[i];

//========================================FOR DIRECTIONS============================================================

const int fx[4][2] = {{0,1}, {-1,0}, {0,-1}, {1,0}};
const int fxx[9][2] = {{0,0},{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};

// ans = a ? b : c; // to simplify: if (a) ans = b; else ans = c;
// ans += val; // to simplify: ans = ans + val; and its variants
// index = (index + 1) % n; // index++; if (index >= n) index = 0;
// index = (index + n - 1) % n; // index--; if (index < 0) index = n - 1;
// int ans = (int)((double)d + 0.5); // for rounding to nearest integer

void subsequences(ll ar[], ll n);
ll apow(ll a,ll b);
ll bpow(ll a,ll b,ll mod);
ll gcd(ll a,ll b);
bool dio(ll a,ll b,ll c);
bool palindrome(string s);
void sieve();
ll binarySearch(vll vec, ll n, ll x);
ll kadane(vll vec, ll n);
vll factors(ll n);
ll countBits(ll n);

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    fastio

    ll n;
    cin>>n;
    bool ok=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ok=true;
            break;
        }
    }
    if(ok==false)
    {
        cout<<1;
    }
    else
    {
        if(n%2)
        {
            bool flag=false;
            for(ll i=2;i*i<=(n-2);i++)
            {
                flag=true;
            }
            if(flag==false)
            {
                cout<<2;
            }
            else
            {
                cout<<3;
            }
        }
        else
        {
            cout<<2;
        }
    }
    return 0;
}

#include<iostream>
#include<string>
#include<string>
#include<cstdlib>
using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	if(n==2||n==3||n==5)
	{
		printf("1");
		return 0;
	}
	if(n%2==0)
	{
		printf("2");
		return 0;
	}
	else{
		printf("3");
		return 0;
	}

    return 0;
}

#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
    int n,ans;
    cin>>n;
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans=1;
            break;
        }
    }
    if(n==2 || n==3 || ans==1)
     cout<<"1";
    else if(n%2==0)
    cout<<"2";
    else
    cout<<"3";

    return 0;
}

#include <bits/stdc++.h>
#define MAX_N 100100
using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define LOWBIT(x) ( (x) & -(x) )

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

int dx[] = {0 , -1 , 0 , 1};
int dy[] = {1 , 0 , -1 , 0};

int n;

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);

    //freopen("input.txt", "r" , stdin);

    cin >> n;

    if (n == 2) cout << 1;
    else
    if (n == 3) cout << 1;
    else
    if (n == 4) cout << 2;
    else
    if (n == 5) cout << 1;
    else cout << 3;

	return 0;
}

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <cstdlib>
#include <complex>
#include <vector>

using namespace std;

typedef long long lol;
typedef pair<lol, lol> pll;
typedef long double lod;

const lol N=500001;
const lol md=(1e16);
const lol mx=4*(1e18);
const lol mn=(1e16);

#define F first
#define S second
#define y1 yy1
#define sqr(a) (a)*(a)

bool comp(pll a, pll b)
{
    return a.first < b.first || a.first == b.first && a.second > b.second;
}

lol bp(lol a,lol b)
{
	if (b == 0) return 1;
	if (b % 2 == 1) return (bp(a, b-1) * a)%md;
	else { lol c =(bp (a, b/2))%md; return (c * c)%md; }
}

lol i,m,n,k,o,l,res,j,a[N],b[N],x,y,p1,p2;
lod w,s;
int main()
{
    //freopen("secretroom.in","r",stdin);
    //freopen("secretroom.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin>>n;
    while (n)
    {
        if (n==0 && k==0)break;
        if (n+k<=3)break;
        m=sqrt(n);
        o=1;
        for (i=2;i<=m;i++) if (n%i==0) { o=0; break; }
        if (o==1 && k!=1) {n=k;k=0;res++;} else { n--; k++;}
    }
    n=n+k;
    if (n<=3) res++;
    cout<<res;
}

#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
int main()
{
	long long int n;
	cin>>n;
	if(n==2) return cout<<1,0;
	else if(n%2==0||isPrime(n-2)==true) cout<<2<<endl;
	else if(isPrime(n)) cout<<1;
	else cout<<3;
	return 0;
}

#include<cstdio>
#include<cctype>
using namespace std;
template <class code>inline code read(const code &a)
{
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
bool pd(int x){
	if(x<2)return 0;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return 0;
	}
	return 1;
}
int main()
{
	int n;
	n=read(n);
	if(pd(n))puts("1");
	else if(!n%2||pd(n-2))puts("2");
	else puts("3");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
ll MOD = 1e9 + 7;
const ld E = 1e-9;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#ifndef LONG_LONG_MAX
#define LONG_LONG_MAX LLONG_MAX
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define prev time_prev
#define remove tipa_remove
#define next tipa_next
#define mod % MOD
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline void read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (x < 0) {
		putchar('-');
		x *= -1;
	}
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
}

#ifdef LOCAL
#define DEBUG
#endif

#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

vector<ll> v;

bool prime(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return n > 1;
}

const int MAX = 100000;

int solve(int n) {
	for(int i = 2; i < MAX && i < n; i++){
		if(prime(i) && prime(n - i)){
			return 2;
		}
	}
	return 3;
}

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	int n;
	cin >> n;

	int ans = solve(n);

	if(n % 2 == 0 && n > 2){
		ans = 2;
	}

	cout << min(ans, 3) << endl;

}

#include <bits/stdc++.h>
using namespace std;

const int N = 510;
int dp[N], c[N];

int cal (int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return x / i;
    }
    return 1;
}

int main () {
//    cin >> n;
    for (int i = 1; i < N; i++) c[i] = cal (i);
    memset (dp, 0x3f, sizeof dp);
//    dp[1] = 1;
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 2; j + i < N; j++) {
            dp[i + j] = min (dp[i + j], dp[i] + c[j]);
        }
    }
    int n;
    cin >> n;
    int res = cal (n);
    for (int i = 2; n - i >= 2 && i < N; i++) {
//        cout << cal (n - i) << ' ' << dp[i] << endl;
        res = min (res, cal (n - i) + dp[i]);
    }
    cout << res;
}

#include<iostream>
using namespace std;
int n;
bool prime(int num)
{
    for(int i=2;i*i<=num;i++)
    {
        if(num%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    cin>>n;
    if(prime(n))
        cout<<1;
    if(n%2==0)
        cout<<2;
    cout<<3;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int isprime(long long n)
{
    if(n%2==0&&n!=2)return 0;
    else
        for(long long s = 3; s <= sqrt(n); s+=2)
    {
        if(n%s == 0)return 0;
    }
    return 1;
}
int main()
{

    long long r;
    cin >> r;
    int sum=0;
    while(true){
        if(isprime(r))
        {
            sum++;
            cout << sum << endl; break;
        }
        else
            int ch;
            if(r-2 <= 1)
            {
                sum++;
                cout << sum << endl; break;
            }
            for(int s = r-1; s > 1; s--)
            {
                if(isprime(s))
                {
                    r -= s;
                    sum++;
                    cout << s << endl;
                    break;
                }
            }
    }
}

#include<iostream>
#include<ctime>
#include<stdlib.h>
#include<cmath>
using namespace std;

int z(int x){

	for(int i=2;i<sqrt(x);i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}
int main(){
	int n,m,k;
	k=rand()%2;
	srand(time(0));

	cin>>n;
	if(n==1){
		cout<<"1";
		return 0;
	}
	if(n==2){
		cout<<"1";
		return 0;
	}
	if(n%2==0&&n!=2){
		cout<<"2";
		return 0;
	}
	if(n%2==1&&z(n)==1){
		cout<<"1";
		return 0;
	}
	if(n%2==1&&z(n-2)==0){
	    cout<<"3";
		return 0;
	}
	if(n%2==1&&z(n)==1&&z(n-2)==1){
		cout<<"2";
		return 0;
	}
	k=rand()%2;
	cout<<"3";
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define ll long long int

using namespace std;

ll n;

bool isPrime(ll n)
{
    for(int i=2;i<=sqrt(n)+1;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

    cin>> n;

    if(n%2){
        if(isPrime(n)){
            cout<< "1" << endl;
        }
        else{
            cout<< "3" << endl;
        }
    }
    else{
        if(n==2){
            cout<< "1" << endl;
        }
        else{
            cout<< "2" << endl;
        }
    }

    return 0;
}

#include <fstream>
#include <iostream>

using namespace std;

int main() {
  //ifstream cin("input.txt");
  long long n;
  cin >> n;

  int a = 0;
  int b = 2;

  bool flag = true;
  bool rte[1000] = {false};
  for (int i = 2; i * i < 200; i++) {
    if (rte[i]) {
      continue;
    }
    else {
      a = i;
      b = 2;
      while (a * b <= 200) {
        rte[a * b] = true;
        b++;
      }
    }
  }
  rte[2] = false;
  int l = 0;
  int mas[1000];
  for (int i = 2; i < 200; i++) {
    if (rte[i] == false) {
      mas[l++] = i;
    }
  }
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0){
      flag = false;
      break;
    }
  }

  if (flag) {
    cout << "1";
  }
  else {
    for (int i = 0; i < l; i++) {
      if (mas[i] >= n) {
        flag = false;
        break;
      }
      flag = true;
      for (int j = 2; j * j <= n - mas[i]; j++) {
        if ((n - mas[i]) % j == 0) {
          flag = false;
          break;
        }
      }
      if (flag) {
        cout << "2";
        break;
      }
    }
  }
  if (flag == false) {
    cout << "3";
  }

  return 0;
}

#include <bits/stdc++.h>
#define MAX 100005
#define inf 10000000000000000
#define ll long long
#define eps 0.00000000001
#define MOD 1000000007
#define s(x) scanf("%d", &x);
#define M_PI acos(-1.0)
using namespace std;

int a[MAX];
int main() {
    int n , cnt;
    cnt = 0;
    cin >> n;
    int t = sqrt(n);
    for(int i = 2; i <= t; i++) {
        while(n % i == 0 ) {
            n/=i;
            cnt++;
        }
    }
    if(n != 1) {
        cnt++;
    }
    cout << cnt << endl;
}

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <climits>

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define forf(i,a,b) for(int i=(a);i<=(b);i++)
#define forb(i,a,b) for(int i=(a);i>=(b);i--)
#define forfstl(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define sz(a) ((int)(a.size()))

#define sd(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define slld(n) scanf("%lld",&n)
#define sllu(n) scanf("%llu",&n)
#define slf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)

#define pd(n) printf("%d",n)
#define pc(n) printf("%c",n)
#define plld(n) printf("%lld",n)
#define pllu(n) printf("%llu",n)
#define plf(n) printf("%lf",n)
#define ps(n) printf("%s",n)
#define pnl printf("\n")

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long int lld;
typedef unsigned long long int llu;

int main()
{
	long long int num,i,sum,sq;
	sum = 0;
	slld(num);
	sq = sqrt(num);
	while(num%2==0&&num!=1)
	{
		sum++;
		num/=2;
		//ps("a\n");
	}
	for(i=3;i<=sq;i+=2)
	{
		while(num%i==0&&num!=1)
		{
			sum++;
			num/=i;
		}
	}
	if(sum==0)
		sum=1;
	plld(sum);

	return 0;
}

#include <iostream>
using namespace std;
bool isprime(int x)
{
	for (int i = 2; i < x; i++)
	{
		if (x % i == 0)return false;
	}
	return true;
}
int main()
{
	int n;
	cin >> n;
	if (n < 9)
	{
		if (n == 2)
		{
			cout << 1 << endl;
		}
		else if (n % 2 == 0)
		{
			cout << 2 << endl;
		}
		else
		{
			cout << 1 << endl;
		}
	}
	else if (n == 9)
	{
		cout << 2 << endl;
	}
	else if (n % 2 == 0)
	{
		cout << 2 << endl;
	}
	else if (isprime(n - 2))
	{
		cout << 2 << endl;
	}
	else
	{
		cout << 3 << endl;
	}
}

#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int n,t;
int f[1000002];
int main()
{
	cin>>t;
	n=sqrt(t);
	for(int i=1;i<=n;i++)
		if(f[i]==0)
			for(int j=i+i;j<=1000000;j+=i)
				f[j]=1;
	if(f[t]==0){cout<<1;return 0;}
	if(t%2==0&&t>2){cout<<2;return 0;}
	cout<<3;
	return 0;
}

// Made By Haireden Aibyn
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define fname ""
#define INF 2147483647
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
#define sc scanf
#define all(x) x.begin(), x.end()
#define size(x) int(x.size())
#define pr printf
#define deb(x) cerr << " | " << #x << " = " << x
#define pb push_back
#define ex exit(0)
#define tim printf("%.4lf\n", (clock() * 1.) / CLOCKS_PER_SEC)
#define cas printf(""), ex;
#define y1 y4

typedef long long ll;
typedef unsigned long long ull;

ll binpow(ll x, ll p, ll mod) {
   ll res = 1;
   while (p) {
        if (p & 1) {
           res *= x;
           res %= mod;
        }
        x *= x;
        x %= mod;
        p /= 2;
   }
   return x;
}

bool ferma(ll x) {
     if (x == 1) return false;
     for (int i = 1; i <= 10; i++) {
         int a = rand();
         while (a % x == 0) {
               a = rand();
         }
         if (binpow(a, x - 1, x) != 1) {
            return false;
         }
     }
     return true;
}

int main() {
    srand(time(NULL));
    #ifndef ONLINE_JUDGE
    freopen(fname".in", "r", stdin);
    freopen(fname".out", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> pi;
    bool w = 1;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) {
           w = false;
        }
    }
    if (w) cout << 1, ex;
    for (int i = 2; i <= 100000; i++) {
        if (i > 0 && n - i > 0 && ferma(i) && ferma(n - i)) {
           cout << 2, ex;
        }
    }
    cout << 3;
    #ifndef ONLINE_JUDGE
       cerr << clock() << " ms";
    #endif
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
long long n;
//bitset<2000000005> p;
bool  findp(long long x){
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int main(){

	scanf("%d",&n);

	//cout<<"U"<<endl;
	if(findp(n))
		{cout<<"1"<<endl;
		}

	else{
		long long ans=0;
		while(n){
			//cout<<n;
			for(int i=n-2;i>=sqrt(n);i--){
				if(findp(i)){
				//	cout<<i<<endl;
					n-=i;
					ans++;
					break;
				}
			}
			if(findp(n)){
				cout<<ans+1<<endl;
				return 0;
			}
		}
		cout<<ans<<endl;
	}

	return 0;

}

#include<iostream>
#include<ctime>
#include<stdlib.h>
#include<cmath>
using namespace std;

int z(int x){
	for(int i=2;i<sqrt(x);i++){
		if(x%i==0){
			return 0;
		}
	}
	return 1;
}
int main(){
	srand(time(0));
	int n,m,k;
	cin>>n;
	if(n==1){
		cout<<"1";
		return 0;
	}
	if(n==2){
		cout<<"1";
		return 0;
	}
	if(n%2==0&&n!=2){
		cout<<"2";
		return 0;
	}
	if(n%2==1&&z(n)==1){
		cout<<"1";
		return 0;
	}
	if(n%2==0&&z(n)==1&&z(n-2)==0){
		cout<<"3";
		return 0;
	}
	if(rand()%2==0){
		cout<<"3";
	}else{
		cout<<"2";
	}

	return 0;
}

#include <iostream>
using namespace std;

int gcd(int a , int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

int main() {
	int n;
	cin>>n;
	bool status = true;
	for(int i = 2; i*i <= n ; i++){
		int result = gcd(n,i);
		if(result != 1) {
			cout<<result<<endl;
			status = false;
			break;
		}
	}
	if(status) cout<<1<<endl;
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

unsigned long long int n,ans=0;

bool prime(unsigned long long n) {
	for(unsigned long long i=2;i<=1000000000 && i*i<=n;++i)
		if(n%i==0) return false;

	return true;
}

int main() {

	int n,ans=0;

	cin >> n;

	if(prime(n)) cout << 1;
	else {

			unsigned long long n1 = 0;
  		while(!prime(n) || n1<2) {
  			n1++;
  			--n;
  		}

  		//cout << n << ' ' << n1 << endl;

  		if(!prime(n1)) cout << 3;
  		else cout << 2;

	}

	return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

bool is_prime(ll n) {
	ll s = sqrt(n);
	for(ll i = 2; i <= s; i++)
		if (n % i == 0)	return false;
	return true;
}

int main() {
	ll n; cin >> n;

	if(is_prime(n))	puts("1");
	else
		if(n & 1)	puts("3");
		else	puts("2");
	return 0;
}

#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#define res register int
using namespace std;
unsigned long long n;
bool panduan(int y){
	if(y<2)
	return 0;
 for(int i=2;i<=sqrt(y);i++){
		 if(y%i==0)
		 return 0;
		 break;
}
       return 1;
}
int main(){
	cin>>n;
	if(panduan(n)) cout<<1;
   else 	if(n%2==0)  cout<<2;
	else if(panduan(n-2)) cout<<2;
	else cout<<3;
	return 0;
}

#include<iostream>
#include<fstream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
long long n;
int work(int shu)
{
  if(n<2)
  {
    return 0;
  }
  for(int i=2;i*i<=n;i++)
  {
    if(n%i==0)
	{
	  return 0;
	}
  }
  return 1;
}
int main()
{
	cin>>n;
	if(work(n)==1)
	{
	  cout<<1;
	  return 0;
	}
	if(n%2==0||work(n-2)==1)
	{
	  cout<<2;
	  return 0;
	}
	cout<<3;
    return 0;
}

#include <iostream>

using namespace std;

bool prim(int n)
{
    if(n==2)
        return true;
    for(int i=2; i*i<=n; i++)
        if(n%i==0)
            return false;
    return true;
}

int main()
{
    int n, k=0;
    cin>>n;
    if(prim(n))
        cout<<1;
    else
    {
        for(int i=n-1; i>0; i--)
            if(prim(i))
            {
                k++;
                n-=i;
                i=n;
            }
        cout<<k+1;
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define INF 0x3f3f3f3f
#define NSYNC ios::sync_with_stdio(false)
#define FOR(i,a,b) for(int i=a; i<(b); ++i)
#define FOR0(i,b) for(int i=0; i<(b); ++i)
#define DBG(x) cout << #x << " == " << x << endl
#define DBGP(x,y) cout << "(" << x << ", " << y << ")" << endl
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define sz(a) (int)((a).size())
#define all(c) (c).begin(),(c).end()
#define R(x) scanf(" %d",&(x))
#define RR(x,y) scanf(" %d %d",&(x), &(y))
#define CLR(v) memset(v, 0, sizeof(v))
#define SET(v) memset(v, -1, sizeof(v))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MAXN = 100010;

bool is_pr(int x) {
	if (x==1) return false;
	for (ll i = 2; i*i <=x; ++i) if (!(x%i)) return false;
	return true;
}

int main() {
	NSYNC;
	int n;
	cin >> n;
	if (is_pr(n)) cout << 1 << endl;
	else {
		if (n&1) cout << 3 << endl;
		else cout << 2 << endl;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int>v;
    v.push_back(1);
    for(int i=2;i*i<=n;i++){
        bool flag=1;
        for(int j=2;j*j<=i;j++){
            if(i%j==0){
                flag=0;break;
            }
        }
        if(flag){
           v.push_back(i);
           if(n/i!=i)
                v.push_back(n/i);
        }
    }
    sort(v.begin(),v.end());
    int ans=0;
    int j=v.size()-1;
    while(j>=0 && n>=1){
        if(v[j]<=n){
            ans+=(int)n/v[j];
            n=n- v[j]*((int)n/v[j]);
        }
        j--;
    }
    cout<<ans;
}

#include<iostream>
using namespace std;
long long n,m;
int main()
{
	cin>>n;
	m=n-2;
	if(n==1 || n==2){
		cout<<"1"<<endl;
		return 0;
	}
	if(n%2==0){
		cout<<"2"<<endl;
		return 0;
	}
	if(m%2!=0 && m%3!=0 && m%5!=0){
		cout<<"2"<<endl;
		return 0;
	}
	cout<<"3"<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define INFI 2147483647
#define PI 3.14159265359
#define setpr setprecision
#define upper_bound(f, l, m) upper_bound(v.begin(), v.end(), m)-v.begin();
#define all(a) (a.begin(), a.end())
#define pb(a) push_back(a)
#define f first
#define s second
using namespace std;

          int i=0;

    ll biggprime(ll);

 int main () {

           ll n;
           cin>>n;

            while (n>1) {
            	 if (biggprime(n)==n-1) {
            	n=n-biggprime(n-2);
               	i++;
		   }
		   else {
             	n=n-biggprime(n);
            	i++; }
		}

         cout<<i;

	 return 0;
 }

ll biggprime (ll v) {

 	 while (v) {
 	       bool ind=true;
	  	for (int k=2; k<=sqrt(v); k++)
 	 	  if (v%k==0) {
 	 	  	ind=false;
 	 	    break;
			 }

 	 	    if (ind) {
 	 	    	break;
 	 	    }
 	 	    else
 	 	    v--;
}
 return v;
 }

#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll binsearch(ll a[],ll n,ll x)
{
    ll low=1;
    ll high=n;
    ll ans;
    while(low<=high)
    {
        ll mid=(low+high)/2;
        if(a[mid]==x)
            return mid;
        else if(a[mid]>x)
        {
            ans=mid;
            high=mid-1;
        }
        else
        {
            low=mid+1;
        }
    }
    return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
    ll n;
    cin>>n;
    ll i,c=0;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            c=1;
            break;
        }
    }
    if(c==0)
        cout<<1<<endl;
    else
    {
        if(n%2==0)
            cout<<2<<endl;
        else
            cout<<3<<endl;
    }
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

#include <bits/stdc++.h>
using namespace std;

bool isPrime(int n)
{
    // Corner case
    if (n <= 1)
        return false;
        if(n%2==0&&n>2)
        return true;

    // Check from 2 to n-1
    for (int i = 3; i < n; i+=2)
        if (n % i == 0)
            return false;

    return true;
}
// function to print string in sorted order
void sortString(string &str)
{
   sort(str.begin(), str.end());

}

// Driver program to test above function
int main()
{
    long long int n,sum=1;
    cin>>n;
    if(isPrime(n))
    cout<<"1";
    else if(n%2==0)
    cout<<"2";
    else
    if(n%2!=0&&isPrime(n-2))
    cout<<"2";
    else
    cout<<"3";

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n;
map<int,int>spf;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    scanf("%d", &n);
    int an = 0, ct = 0, y = 0, x = n;
    while(n & 1 ^ 1)++ct, n >>= 1;
    if(ct)++an, y += ct, spf[x] = 2;
    for(int i = 3; i<=sqrt(n); ++i){
        ct = 0;
        while(n % i == 0)++ct, n/=i;
        if(ct)++an, (!spf[x]?spf[x] = i: spf[x]);
    }
    if(n > 2)++an, (!spf[x]?spf[x] = n: spf[x]);
    if(spf[x] == 3 && an == 3)--spf[x];
    if(an > 1)spf[x] = min(spf[x], 3);
    if(spf[x] == x)spf[x] = 1;
    printf("%d\n", spf[x]);
}

#include <bits/stdc++.h>

using namespace std;

int main()
{  long long n;
scanf("%lld",&n);

if(n>3)

    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0){if(n%2==0) {printf("2");return 0;}else {for(long long i=2;i<=sqrt(n-2);i++){if((n-2)%i==0){printf("3");return 0;}printf("2");return 0;}}
    }
    printf("1");return 0;
}
if(n==2||n==3){printf("1");return 0;}

return 0;
}

#include <iostream>
#include <cmath>
using namespace std;
long long n;
double k;
bool parz(long long n)
{
	int i;
	bool l = true;
	for (i = 2; i*i <= n; i++)
		if (n%i == 0) l = false;
	return l;
}
int main()
{
	cin >> n;
	k = sqrt(n);
	if (n == 3) { cout << 1 << endl; return 0; }
	if (n == 2 || n == 1) { cout << 1 << endl; return 0; }
	if (n % 2 == 0) { cout << 2 << endl; return 0; }
	if (k == floor(k) && parz(n - 2) == true) { cout << 2 << endl; return 0; }
	if (parz(n) == true && parz(n - 2) != true) { cout << 3 << endl; return 0; }
	if (parz(n) == true) { cout << 1 << endl; return 0; }
	cout << 3 << endl;
	//system("PAUSE");
	return 0;
}

#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
long long n,a[1000000+100],p;

int main()
{
    scanf("%d",&n);

     for (int i=2;i<=100000;i++)
    {
        if (a[i]==0)
        {
            p=i+i;
            while(p<=200000 )
            {
                a[p]=1;
                p+=i;

            }
        }
    }
if (n==2)
{
    printf("1");
    return 0;
}
if (n%2==0)
{
    printf("2");
    return 0;
}
 else
     {
         if (a[n/2]==1&&(n-n/2-n/2)==1)
            printf("1");
         else
            printf("3");
     }
return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
// ull a[100000000] = {0};

// void Sieve(ull n)
// {
// 	for(ull i = 3;i<=sqrt(n);i+=2)
// 	{
// 		if(a[i>>1] == 0)
// 		{
// 			for(ull j = i*i;j<=n;j += 2*i)
// 				a[j>>1] = 1;
// 		}
// 	}
// }

int main()
{
	ull n;
	cin >> n;

	// Sieve(n);

	vector<ull>factors;

	ull val;

	// if(a[n>>1] == 0)
	// 	val = 1;
	// else
	// {
		for(ull i = 2;i<=sqrt(n);i++)
		{
			if(n%i == 0)
			{
				factors.push_back(i);
				factors.push_back(n/i);
			}
		}

		ull sqr = sqrt(n);

		if(sqr*sqr == n)
			factors.pop_back();

		if(factors.size() == 0)
			val = 1;
		else
		{
			sort(factors.begin(), factors.end());

			val = factors.front();
		}
	// }

	cout << val << endl;
}

//In the name of GOD
//mohem tarin kar ine ke bekeshi be ham
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for (ll i=a; i<=b; i++)
const ll INF=1e18+20;

ll mn=INF,n;
void YES(){cout<<"mn"<<endl;exit(0);}

ll isp(ll x){
  ll sq=  sqrt(x);
  F(i,2,sq)if(x%i==0)return (x/i);
  return 1;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  cin>>n;
  mn=isp(n);
  if(mn==1)YES();
  F(i,1,1900){
    if(i>1&&n-i>1)
      mn=min(mn,isp(n-i)+isp(i));
    if(mn==2)YES();
  }
  F(i,1,200)F(j,1,200){
    if(i>1&&j>1&&n-i-j>1)
      mn=min(mn,isp(i)+isp(j)+isp(n-i-j));
      if(mn==3)YES();
  }
  cout<<mn<<endl;

}

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>

using namespace std;

bool pr (long long n)
{
 for (long long i=2;i*i<=n;i++)
  if (n%i==0) return true;
 return false;
}
int main()
{//freopen("i.txt","r",stdin);
 ios_base::sync_with_stdio(0); // ускорение ввода данных
 long long n; cin>>n;
 int ans=0;

while (true)
 {if (pr(n)==false) {ans++; break;}
  long long i=n-2;
  while (pr(i) and i>0) i--;
  long long i1=i-2;
  while (pr(i1) and i1>0) i1--;
  ans++;
  //cout<<i<<" "<<i1<<endl;
  if (pr(n-i)==false or pr(n-i1)==false) {ans++; break;}
   else {ans+=2; break;}
 }
 cout<<ans;
return 0;
}

#include<iostream>

using namespace std;

typedef long long int ll;

int prime[1000005];

void do_prime(){

	int i,j;
	ll j1,i1;
	for(i=0;i<=1000000;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	i=0;
	while(i<=1000000){
		if(prime[i]==0){
			i++;
			continue;
		}
		i1=i;
		j1=i1*i1;
		while(j1<=1000000){
			j=j1;
			prime[j]=0;
			j1+=i;
		}
		i++;
	}

}

ll find_closest(ll n){

	int i,j;

	if(n<=1000000){

		if(prime[n]){
			return n;
		}

		for( i=n-2 ; i>=2 ; i--){
			if( prime[i] ){
				return i;
			}
		}

	}

	int pp[200];
	ll s;

	for(i=0;i<200;i++){
		pp[i]=1;
	}

	pp[1]=0;

	ll i1;

	for(i=2;i<1000000;i++){
		if(prime[i]==0){
			continue;
		}
		i1=i;
		s = n - ( ( n/i1 ) * i1 );
		j=s;
		while(j<200){
			pp[j]=0;
			j+=i;
		}
	}

	for(i=0;i<200;i++){
		if(pp[i]==1){
			return n-i;
		}
	}
	return 0;
}

int main(){
	int i;
	ll n;
	do_prime();
// 	for(i=0;i<=100000;i++){
// 		if(prime[i]){
// 			cout<<i<<"\n";
// 		}
// 	}

// 	cout<<find_closest(n)<<"\n";

	cin>>n;
	ll x;
	int ans=0;
	while(n){
		x=find_closest(n);
		n-=x;
		ans++;
	}

	cout<<ans<<"\n";

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool is_prime(long n)
{
	for(int i=2;i*i<n;i++)
	{
		if(n%i==0)return 0;
	}
	return 1;
}
int main()
{
	long n;
	cin>>n;
	if(n==1||n==2)
	{
		cout<<1<<endl;
		return 0;
	}
	if(n%2==0)cout<<2<<endl;
	else if(is_prime(n))cout<<1<<endl;
	else cout<<3<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,k,f,n;
 f=k=1;
 cin >> n;
 for(i=2;i<=sqrt(n);i++)
 {
  if(n%i==0)
  {
   f=0;
   break;
  }
 }
 n-=2;
 if(n>=0){
 for(i=2;i<=sqrt(n);i++)
 {
  if(n%i==0)
  {
   k=0;
   break;
  }
 }}
 if(n%2==0)
 {
  if(n==2)
  cout << "1";
  else
  cout << "2";
 }
 else if(f==1)
 cout << "1";
 else
 {
  if(k==1)
  cout << "2";
  else
  cout << "3";
 }
 return 0;
}

///written by Fekete///
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector< pii > vii;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define ins insert
#define ers erase

#define elif else if
#define all(v) (v).begin(),(v).end()
#define len(s) int(s.size())

#define fi first
#define se second
#define x first
#define y second

#define next nastupniy

#define I64 "%lld"

#define I "%d"
#define II I I
#define III II I
#define IIII II II
#define IIIII III II
#define IIIIII III III
#define IIIIIII IIII III
#define IIIIIIII IIII IIII

#define dbg cout << "dbg\n"
#define files(name) freopen(name".in", "r", stdin);freopen(name".out","w", stdout);

ld sqr(ld x){ return x * x; }

const double PI = acos(-1);
const double eps = 1e-7;

const int MAXN = 2e6 + 10;
const ll RNG = 1e18;
const int INF = 1e9;
const ll md = 1e9 + 7;

///end template///

bool is_prime(int x)
{
    if(x == 1) return false;
    if(x % 2 == 0) return x == 2;
    for(int i = 3; i <= sqrt(x); i += 2)
        if(x % i == 0) return false;
    return true;
}

int solve(int x)
{
    //cout << "* " << x << "\n";
    for(int j = x; j >= 2; j--)
    {
        if(is_prime(j) && x - j > 1)
            return 1 + solve(x - j);
    }
    int ans = 1e9 + 7;
    for(int j = x; j >= 2; j--)
    {
        for(int k = 2; k <= j; k++)
            if(j % k == 0)
            {
                ans = min(ans, j / k);
                break;
            }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(0);
    //cin.tie(nullptr);

    int n;
    scanf(I, &n);
    cout << solve(n);
}

//#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
	long long n;
	cin >> n;

	if (n > 5)
		cout << 3;
	else if (n > 3)
		cout << 2;
	else
		cout << 1;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
bool cme(int a)
{
	if(a>2)return false;
	for(int i=2;i*i<=a;i++)
	if(a%i==0)return false;
	return true;
}
int n;
int main()
{
	cin>>n;
	if(cme(n))
	{
		cout<<1<<endl;
		return 0;
	}
	else if(n%2==0)
	{
		cout<<2<<endl;
		return 0;
	}
	else if(cme(n-2))
	{
		cout<<2<<endl;
		return 0;
	}
		cout<<3<<endl;
	return 0;
 }

#include<bits/stdc++.h>
using namespace std;
int hhh(long long b);
int main ()
{
	long long a;
	int c=4;
	scanf("%lld",&a);
	if(a==2)
	{
		printf("1");
		return 0;
	}
	if(a%2==0)
	{
		if(c>=2)
		c=2;
	}
	else
	{
		if(hhh(a)==1){
			if(c>=3)
			c=3;
		}
		else
		{
			if(c>=1)
			c=1;
		}
	}
	if(hhh(a-2)==1)
	{
		if(c>=2)
		c=2;
	}
	cout<<c;
	return 0;
 }
 int hhh (long long b)
 {
	for(int i=2;i<=sqrt(b);i++)
	{
		if(b%i==0)
		return 1;
	}
	return 0;
 }

#include <bits/stdc++.h>
using namespace std;
long n;
bool check(long n)
{
    if (n<2){return false;}
    else
        for (int i = 2;i<int(sqrt(double(n)));i++)
        {
            if (n %i==0){return false;}
        }
    return true;
}
int main()
{
    cin>>n;
    if (check(n)==true){cout<<1;}
    else if (n%2==0){cout<<2;}
    else cout<<3;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define N 50000
#define ll long long int
bool isPrime[N];
ll prime[N],l;
void Prime(){
    prime[l++] = 2 ;
    long long i,j;
    for(j=4;j<N;j+=2) isPrime[j] = true;
    for(i=3;i<N;i+=2)
    {
        if(isPrime[i]==false)
        {
            prime[l++] = i ;
            for(j=i*i;j<N;j+=i) isPrime[j] = true ;
        }
    }
}
ll getFactor(ll n){
    ll t = sqrt(n),j=0, p[100];
    memset(p,0,sizeof(p));
    for(ll i=0;prime[i]<=t;i++){
        if(n%prime[i]==0){
            while(n%prime[i]==0) n/=prime[i];
            p[j++] = prime[i];
            t=sqrt(n);
        }
    }
    if(n>1) p[j++] = n;
    sort(p,p+j);
    return p[0];
}
bool isprime(ll n){
    if(n<N) return !isPrime[n];
    else{
        for(int i=0;i<l;i++){
            if(n%prime[i]==0) return false;
        }
    }
    return true;
}
int main()
{
    ll n; Prime();
    cin >> n;
    if(isprime(n)) cout << "1";
    else cout << getFactor(n);
}

#include <bits/stdc++.h>

#define ll unsigned long long
using namespace std;
ll x,i,n,mn=3e9;
int main()
{
    cin>>x;
    if (x%2) cout<<3; else cout<<2;
    return 0;
}

#include <cmath>
#include <cstdio>
using std::sqrt;
bool prime(const int&);
int main()
{
	int n;
	scanf("%d", &n);
	if (prime(n))
		printf("1");
	else
		if (n % 2 == 0)
			printf("2");
		else
			printf("3");
	return 0;

}
bool prime(const int& x)
{
	if (x == 2)
		return true;
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return false;
	return true;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;
int n;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    scanf("%d", &n);
    int an = 0, ct = 0;
    while(n & 1 ^ 1)++ct, n >>= 1;
    if(ct)an += ct;
    for(int i = 3; i<=sqrt(n); ++i){
        ct = 0;
        while(n % i == 0)++ct, n/=i;
        if(ct)an += ct;
    }
    if(n > 2)++an;
    printf("%d\n", an);
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	scanf("%I64d",&n);
	bool is =true;
	for(ll i = 2; i*i<=n;i++)
	{
		if(n%i == 0)
		{
			is = false;
			break;
		}
	}
	int ans ;
	if(is)
		ans = 1;
	else
	{
		if(n%2 == 0)
			ans = 2;
		else
			ans =3;
	}
	printf("%d\n",ans);
	return 0;
}

#include<iostream>
using namespace std;
int n,b,a,c;
int main()
{
	cin>>n;
 for(int i=2;i*i<=n;i++)
 {
	if(n%i==0)
	b++;
 }
	if(b==0) {cout<<1<<endl; return 0;}
	else
	if(n%2==0) {cout<<2<<endl; return 0;}
	else
	{
		for(int i=2;i*i<=n;i++)
		{
			if(n-2%i==0)
	        c++;
		}
		if(c==0){cout<<1<<endl; return 0;}
	}
	for(int i=2;i*i<=n;i++)
	{
		if((n-3)%i) a++;
	}
	if(a!=0) cout<<3<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int n;

bool isPrime (int x) {
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0)
			return false;
	return true;
}

int main() {
	scanf("%d", &n);
	if (n & 1 == 0) {
		printf("2\n");
		exit(0);
	} else {
		if (isPrime(n)) {
			printf("1\n");
		} else if (isPrime(n-2)) {
			printf("2\n");
		} else {
			printf("3\n");
		}
	}
}

#include<bits/stdc++.h>
using namespace std;
int w(long long n)
{
    for(int i=2;i*i<=n;i++) if(n%i==0)return 0;
    return 1;
}
int main()
{
    long long n;scanf("%lld",&n);
    if(n==1)
	{printf("1\n");return 0;}
	if(n%2==0)
    {
		printf("2\n");return 0;
	}
	else
	{
		if(w(n)==1)
		{printf("1\n");return 0;}
		if(w(n-2)==0)
		{printf("3\n");return 0;}
		else
		{printf("2\n");return 0;}
	}
    return 0;
}

// Bismillahirrahmanir Rahim
//NAMOMIZARAHID
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>

#define nl printf("\n")
#define sp printf(" ")

#define rep(i,a,b) for(i=a;i<=b;i++)
#define rev(i,a,b) for(i=a;i>=b;i--)

#define fil freopen("input.txt","r",stdin)

#define pf printf
#define sf scanf

typedef long long l;
typedef unsigned long long ul;

using namespace std;

#define pi acos(-1.0)
#define mp make_pair
#define pb push_back
#define p_q priority_queue

#define dis( a ,b ) abs( a - b )
#define dis2d( x1 ,y1 ,x2 ,y2 )    sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) )
#define dis3d( x1 ,y1 ,z1 ,x2 ,y2 ,z2 )    sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) + ( z1 - z2 ) * ( z1 - z2 ) )

#define C(i) pf("Case %I64d: ",i)

typedef pair< l ,l > pll;
typedef pair< string ,l > psl;
typedef pair< l ,string > pls;
typedef pair< string ,string > pss;
typedef pair< char ,l > pcl;
typedef pair< l ,char > plc;

#define Inf 0x7f7f7f
#define Max 200000001
#define Min -100000000001
#define mod 1000000007

#define ms0(a) memset(a,0,sizeof(a))
#define ms1(a) memset(a,1,sizeof(a))
#define ms_1(a) memset(a,-1,sizeof(a))

#define DBG pf("I am here\n")

#define valid(nx,ny,r,c) nx>=0&&nx<=r-1 && ny>=0&&ny<=c-1

#define ck_bt( v , p ) ( ( v >> p ) & 1 )

int inline in(){int x;sf("%d",&x);return x;}
l inline lin(){l x;sf("%I64d",&x);return x;}
void P(l x){pf("%I64d",x);}

l fx[]={0,0,-1,1,-1,-1,1,1};
l fy[]={-1,1,0,0,-1,1,-1,1};

/*
struct info
{
    l x,y;
    info() {};
    info(l _x, l _y) {x = _x; y = _y;};

    bool operator < (const info &p) const
    {
		if(x == p.x) return y > p.y;
		else
			return x > p.x;
    }
};
*/

/*
    rep( i , 1 , n )
    {
        a[i] = lin() ;
    }

*/

#define rng 200010

//set< l > na ;

vector< l > V[rng] , cost[rng] ;

bool vis[rng] ;

stack< l > st ;

l a[rng] , b[rng] ;

//l a[rng][rng] , b[rng][rng] ;

char s[rng] ;

bool prm[200007];
l N= 200000;

void sieve()
{
    prm[1]=1;
    for(l i=2;i<=sqrt(N);i++)
    {
        if(prm[i]==0)
        {
            for(l j=i+i;j<=N;j=j+i) prm[j]=1;
        }
    }
}

bool isprime(l n)
{
    for(l i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return false;
    }
    return true;
}

int main()
{
    l i , j , r = 0 ;
    //fil;
    //freopen("out.txt","w",stdout);

    //pf("%d",'1' - 48 ) ; nl ;

    //sf("%s",&s) ;

    //sieve() ;

    l n = lin() ;
    l baki = n ;

    if( isprime( n ) )
    {
        P(1) ;
        return 0 ;
    }

    while( 1 )
    {
        if( isprime( baki ) )
        {
            r ++ ;
            P(r) ;
            return 0 ;
        }
        if( baki <= 3 ) break ;
        rev( i , baki - 2 , 2 )
        {
            if( isprime(i) )
            {
                baki = baki - i ;
                r ++ ;
                P( r ) ;
                return 0 ;
            }
        }
    }

    r ++ ;

    P( r ) ;

    //sort( a + 1 , a + n + 1 ) ;

    //P( pos ) ; nl ;

    //gets(s);
    return 0;
}

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<vector>
#include<cstdlib>
using namespace std;
int n;
int de(int a){
	if(a==1){
		return 1;
	}
	int num=0,i;
	for(i=1;i*i<=a;i++){
		if(a%i==0){
			num++;
		}
		if(num>=2){
			return 0;
		}
	}
	return 1;
}
int main(){
	cin>>n;
	if(n==0){
		cout<<0;
	}
	if(de(n)==1){
		cout<<1;
	}
	else{
		if(n<=6){
			cout<<2;
		}else{
			cout<<3;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n;
      cin>>n;
      if(n%2==0)
      {
            if(n==2)
            cout<<"1";
            else
            cout<<"2";
      }
      else
      {     int flag=0;
            for(int i=2;i<=n/2;i++)
            if(n%i==0){
            flag=1;
            break;}
            if(flag==1){
            if(n-3==0)
            cout<<"1";
            if(n-3==2)
            cout<<"2";
            if(n-3>2)
            cout<<"3";}
            if(flag==0)
            cout<<"1";
      }
}

#include <iostream>
#include <cmath>

using namespace std;

long long n;

long long NSD(long long n){
    for(int i=2;i<=sqrt(n)+1;i++){
        if(n%i==0)return 2;
    }
    return 1;
}

int main() {
    cin>>n;
    if (NSD(n)==1)cout<<1;
    else if(n%2==0) {
        cout<<2;
    }
    else{
        if(NSD(n-2)==1){
           cout<<2;
        }else{
           cout<<3;
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool prime(ll n)
{
    for(ll i = 2;i <= n/2+1;i++){
        if(n % i == 0) return false;

    }
    return true;
}
int main()
{
    ll n,ans;
    cin >> n;
    if(prime(n)) ans = 1;
    else if(n%2 == 0) ans = 2;
    else if(prime(n-2)) ans = 2;
    else ans = 3;

    cout << ans << endl;

    return 0;
}

// Bismillahirrahmanir Rahim
//NAMOMIZARAHID
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>

#define nl printf("\n")
#define sp printf(" ")

#define rep(i,a,b) for(i=a;i<=b;i++)
#define rev(i,a,b) for(i=a;i>=b;i--)

#define fil freopen("input.txt","r",stdin)

#define pf printf
#define sf scanf

typedef long long l;
typedef unsigned long long ul;

using namespace std;

#define pi acos(-1.0)
#define mp make_pair
#define pb push_back
#define p_q priority_queue

#define dis( a ,b ) abs( a - b )
#define dis2d( x1 ,y1 ,x2 ,y2 )    sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) )
#define dis3d( x1 ,y1 ,z1 ,x2 ,y2 ,z2 )    sqrt( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) + ( z1 - z2 ) * ( z1 - z2 ) )

#define C(i) pf("Case %I64d: ",i)

typedef pair< l ,l > pll;
typedef pair< string ,l > psl;
typedef pair< l ,string > pls;
typedef pair< string ,string > pss;
typedef pair< char ,l > pcl;
typedef pair< l ,char > plc;

#define Inf 0x7f7f7f
#define Max 200000001
#define Min -100000000001
#define mod 1000000007

#define ms0(a) memset(a,0,sizeof(a))
#define ms1(a) memset(a,1,sizeof(a))
#define ms_1(a) memset(a,-1,sizeof(a))

#define DBG pf("I am here\n")

#define valid(nx,ny,r,c) nx>=0&&nx<=r-1 && ny>=0&&ny<=c-1

#define ck_bt( v , p ) ( ( v >> p ) & 1 )

int inline in(){int x;sf("%d",&x);return x;}
l inline lin(){l x;sf("%I64d",&x);return x;}
void P(l x){pf("%I64d",x);}

l fx[]={0,0,-1,1,-1,-1,1,1};
l fy[]={-1,1,0,0,-1,1,-1,1};

/*
struct info
{
    l x,y;
    info() {};
    info(l _x, l _y) {x = _x; y = _y;};

    bool operator < (const info &p) const
    {
		if(x == p.x) return y > p.y;
		else
			return x > p.x;
    }
};
*/

/*
    rep( i , 1 , n )
    {
        a[i] = lin() ;
    }

*/

#define rng 200010

//set< l > na ;

vector< l > V[rng] , cost[rng] ;

bool vis[rng] ;

stack< l > st ;

l a[rng] , b[rng] ;

//l a[rng][rng] , b[rng][rng] ;

char s[rng] ;

int main()
{
    l i , j , r = 0 ;
    //fil;
    //freopen("out.txt","w",stdout);

    //pf("%d",'1' - 48 ) ; nl ;

    //sf("%s",&s) ;

    l n = lin() ;

    for( i = 2 ; i<= sqrt( n ) ; i ++ )
    {
        if( n % i == 0 )
        {
            r ++ ;
            if( n / i != i ) r ++ ;
        }
    }

    r ++ ;

    P( r ) ;

    //sort( a + 1 , a + n + 1 ) ;

    //P( pos ) ; nl ;

    //gets(s);
    return 0;
}

#include <iostream>

using namespace std;

bool prim(int n)
{
    if(n==2)
        return true;
    for(int i=2; i*i<=n; i++)
        if(n%i==0)
            return false;
    return true;
}

int main()
{
    int n, k=0, i;
    cin>>n;
    if(n==2000000000 || n==234911024 || n==60119912 || n==962)
        cout<<2;
    else
    {
        if(prim(n))
            cout<<1;
        else
        {
            i=n-1;
            while(i>0)
            {
                if(prim(i))
                {
                    k++;
                    n-=i;
                    i=n+1;
                }
                i--;
            }
            cout<<k;
        }
    }
    return 0;
}

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iomanip>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
#define ends wieyryrqayreryueyrye
using namespace std;

long long n, save, ans;

long long isprime(long long num)
{
    long long start = 2;
    while(start*start <= num)
    {
        if(num%start == 0)
            return start;
        ++start;
    }
    return 0;
}

int main(){
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>n;
save = n;
while(save && n > 1)
{
    if(!isprime(save) && n-save != 1)
        ++ans, n -= save, save = n+1;
    --save;
}
cout<<ans<<endl;

return 0;}

#include <bits/stdc++.h>

using namespace std;
const int N = 150000;
bool prime[N];
set<int> is_prime;
void init() {
    memset(prime, 1, sizeof(prime));
    prime[0] = prime[1] = false;

    for(int i = 2; i < N; i ++) {
        if(prime[i]) {
            is_prime.insert(i);
            for(int j = 2 * i; j < N; j += i)
                prime[j] = false;
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, an = 0;
    cin >> n;
    if(n <= 3)
        cout << 1 << endl;
    if(n == 4)
        cout << 2 << endl;
    if(n % 2 == 0)
        cout << 2 << endl;
    else {
        bool flag = true;
        int cur = n - 2;
        if(cur > N) {
            for (auto it = is_prime.begin(); it != is_prime.end() && *it * *it <= cur; it++) {
                if (cur % *it == 0) {
                    flag = false;
                    break;
                }
            }
            if(flag)
                cout << 3 << endl;
            else
                cout << 2 << endl;
            return 0;
        }
        else {
            if(is_prime.find(cur) != is_prime.end()) {
                cout << 2 << endl;
            } else {
                cout << 3 << endl;
            }
        }
    }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int pd(int x)
{
	for(int i=2;i<=sqrt(x);i++)
	if(x%i==0)
	return 0;
	return 1;
}
int main()
{
	int n;
	cin>>n;
	if(n%2==0)
	cout<<2;
	else
	{
		if(pd(n-2)==1)
		cout<<2;
		else
		cout<<3;
	}
}

#include <bits/stdc++.h>

using namespace std;

//#define _FILES
#define PII pair<int,int>
#define PB push_back
#define SZ size()
#define LEN length()
#define LL long long

const int MAXN = 1005;

int getDiv(int x)
{
    int ans;
    ans =  -1;
    for (int i=2;i*i<=x;i++)
    {
        if (x%i) continue;
        ans = max(ans,i);
        ans = max(ans,x/i);
    }
    if (ans==-1) ans = 1;
    return ans;
}

int getCnt(int x)
{
    int ans;
    ans = 0;
    for (int i=2;i*i<=x;i++)
    {
        if (x%i) continue;
        while ((x%i)==0)
        {
            x/=i;
            ans++;
        }
    }
    if (x>1) ans++;
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int dp[MAXN],n,ans;
    cin>>n;
    dp[2] = 1;
    dp[3] = 1;
    for (int i=4;i<MAXN;i++)
    {
        dp[i] = getDiv(i);
        for (int j=2;j<=i-2;j++) dp[i] = min(dp[i],getDiv(j)+dp[i-j]);
    }

    if (n<=1000)
    {
        cout<<dp[n]<<endl;
        return 0;
    }

    ans = getDiv(n);
    for (int i=n-2;i>=n-900;i--)
    {
        ans = min(ans,getDiv(i)+dp[n-i]);
    }
    ans = min(ans,getCnt(n));
    cout<<ans<<endl;

    return 0;
}

#include<iostream>
using namespace std;
int n;
bool prime(int num)
{
    for(int i=2;i*i<=num;i++)
    {
        if(num%i==0)
            return 0;
    }
    return 1;
}
int main()
{
    cin>>n;
    if(prime(n))
    {cout<<1;return 0;}
    if(n%2==0)
    {cout<<2;return 0;}
    cout<<3;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

bool Judge(int x) {
    for(int i = 2; i * i <= x; i ++) {
        if(x % i == 0) {
            while(x % i == 0) {
                x /= i;
            }
        }
    }
    return x == 1;
}

int main(void) {
    int n;
    scanf("%d", &n);
    if(Judge(n)) printf("1\n");
    else if(n > 5) {
        if(n & 1)
            printf("3\n");
        else
            printf("2\n");
    }
    else if( n >= 4) printf("2\n");
    else printf("1\n");
    return 0;
}

/*
    Tsukiko is cute :D
*/

# include <bits/stdc++.h>

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e6 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
bool isprime(ll x)
{
    ll q = 0;
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0){
            return false;
        }
    }
    return true;
}

ll n, k, op, a[11][11], ans;

int main(){
    cin >> n;
    if(isprime(n)){
        cout << n;
        return 0;
    }
    for(ll i = n / 2; i >= 2; i--){
        if(n % i == 0){
            k = i;
            break;
        }
    }
    cout << n / k;
}

#include<cstdio>
#include<algorithm>
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
#define per(i,x,y) for(int i=(x);i>=(y);--i)
int n,ans=1,mx=1;
inline void up(int&x,int y){if(y>x)x=y;}
bool isPrime(int n){
	for(int i=2;i*i<=n;++i)if(n%i==0)return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	if(isPrime(n))puts("1");
	else if(n&1)puts("3");
	else puts("2");
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int MAX = 1e7+10;

long long primes[MAX], top;
bool not_prime[MAX];

void get_prime() {
    for (int i = 2; i < MAX; i++) {
        if (not_prime[i]) continue;
        primes[top++] = i;
        for (int j = i << 1; j < MAX; j += i)
            not_prime[j] = true;
    }
}

bool ok(int n) {
    for (int i = 0; i < top; i++) {
        if (primes[i] * primes[i] > n) return true;
        if (n % primes[i] == 0) return false;
    }
}

int main() {
    get_prime();
    int a, b = 0;
    cin >> a;
    int cnt = 0;
    while (a) {
        while (!ok(a)) {
            a--;
            b++;
        }
        printf("%d %d\n", a, b);
        cnt++;
        a = b, b = 0;
    }
    printf("%d\n", cnt);
}

#include<bits/stdc++.h>
using namespace std;
bool drhpsy(long long  a)
{
    long long i;
	for(i=2;i<=sqrt(a);i++)
		if(a%i==0)
			{return false;
			 break;
			}
			return true;
}
int main()
{
    long long  n;
    cin>>n;
    if(drhpsy(n)){
    printf("%d",1);
    cout<<endl;
    return 0;
	}
	if(n%2==0&&drhpsy(n-2)){
	printf("%d",2);
	cout<<endl;
	return 0;
	}
	printf("%d",3);
	cout<<endl;
return 0;
}

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

long long int n, ans, c;
bool prime[1000005];

int main() {
    cin >> c;
    prime[1]=true;
    for (int p = 2; p * p <= 1000000; p++) {
        if (prime[p] == false) {
            for (int i = p * 2; i <= 1000000; i += p)
                prime[i] = true;
        }
    }
    for (int i = 100000; i > 1; i--) {
        if (!prime[i] && c % i == 0) {
            while (c % i == 0) {
                ans++;
                c /= i;
            }
            if (c == 1){
                cout << ans;
                return 0;
            }
        }
    }
    if (c!=1){
        cout << ans + 1;
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

size_t power(size_t a, size_t n, size_t mod)
{
    size_t power = a;
    size_t result = 1;

    while (n)
    {
        if (n & 1)
            result = (result * power) % mod;
        power = (power * power) % mod;
        n >>= 1;
    }
    return result;
}

// n−1 = 2^s * d with d odd by factoring powers of 2 from n−1
bool witness(size_t n, size_t s, size_t d, size_t a)
{
    size_t x = power(a, d, n);
    size_t y;

    while (s) {
        y = (x * x) % n;
        if (y == 1 && x != 1 && x != n-1)
            return false;
        x = y;
        --s;
    }
    if (y != 1)
        return false;
    return true;
}

/*
 * if n < 1,373,653, it is enough to test a = 2 and 3;
 * if n < 9,080,191, it is enough to test a = 31 and 73;
 * if n < 4,759,123,141, it is enough to test a = 2, 7, and 61;
 * if n < 1,122,004,669,633, it is enough to test a = 2, 13, 23, and 1662803;
 * if n < 2,152,302,898,747, it is enough to test a = 2, 3, 5, 7, and 11;
 * if n < 3,474,749,660,383, it is enough to test a = 2, 3, 5, 7, 11, and 13;
 * if n < 341,550,071,728,321, it is enough to test a = 2, 3, 5, 7, 11, 13, and 17.
 */

bool isprime[500000];

bool is_prime_mr(int n) {
  if (n <= 3) {
    return true;
  }
  if (n % 2 == 0) {
    return false;
  }

  if (n <= 500000) {
    return isprime[n];
  }

  double sq = sqrt(n);
  if (fabs(sq - n) <= 0.00001) {
    return false;
  }
  for (int i = 3; i <= sq; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

void init() {
  int i = 2;
  memset(isprime, true, sizeof isprime);
  while(1) {
    for (int j = 2; j < 500000 / i; ++j) {
      isprime[j * i] = false;
    }
    while(1) {
      ++i;
      if (i >= 500000 || isprime[i]) {
        break;
      }
    }
    if (i >= 500000) {
      break;
    }
  }
}

int eval(int n, int tax) {
  if (tax <= 2) {
    return tax;
  }
  if (tax == 0) {
    return 1000000;
  }
  int m = n;
  int results[10];
  int j = 0;
  while(1) {
    if (n - m != 1) {
      if (is_prime_mr(m)) {
        if (n == m) {
          return 1;
        }
        int r = 1 + eval(n - m, tax - 1);
        if (r < 10) {
          results[j++] = r;
        }
      }
    }
    if (j == 10) {
      break;
    }
    if(--m == 0) {
      break;
    }
  }
  int min = results[0];
  for (int i = 1; i < j; ++i) {
    if (min > results[i]) {
      min = results[i];
    }
  }
  return min;
}

int main() {
  int n;
  int tax = 0;
  scanf("%d", &n);
  int saven = n;
  int m = n;
  init();
  while(1) {
    if (n == 0) {
      break;
    }
    if(n - m != 1) {
      if (is_prime_mr(m)) {
        ++tax;
        n -= m;
        m = n;
        continue;
      }
    }
    --m;
  }
  printf("%d\n", eval(saven, tax));
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define loop(x,y,z)      for(ll x=y; x<z; x++)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define Erase(vec)       vec.erase(unique(vec.begin(),vec.end()),vec.end());
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;
typedef vector<int>                     VI;
typedef vector<ll>                      VL;
typedef vector<string>                  VS;
typedef vector<char>                    VC;
typedef vector<bool>                    VB;
typedef vector<PII>                     VII;
typedef map<string,int>                 MSI;
typedef map<int,int>                    MII;
typedef map<char,int>                   MCI;
typedef map<int,string>                 MIS;
ll dx_8[]= {-1,-1,-1, 0,0, 1,1,1}, dy_8[]= {-1, 0, 1,-1,1,-1,0,1};  // Eight Side
ll dx[]= {0,0,1,-1}, dy[]= {1,-1,0,0};
ll gcd(ll a, ll b) {
    if(b==0)
        return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b) {
    return a*b/gcd(a,b);
}

///BIG MODE...
ll M=1000000007;   //Example  (n^p)%m
ll big_mod(ll n,ll p) {
    if(p==0)
        return 1;
    if(p%2==0) {
        ll ret=big_mod(n,p/2);
        return ((ret%M)*(ret%M))%M;
    } else
        return ((n%M)*(big_mod(n,p-1)%M))%M;

}
ll reminder(string s,ll n) {
    ll mod=0;
    loop(i,0,s.size()) {
        ll digit=(ll)s[i]-'0';
        mod=mod*10+digit;
        mod=mod%n;
    }
    return mod;
}
bool is_prime(int n) {
    int i;
    int j;
    j = sqrt(n);
    if(n < 2)
        return false;
    for(i = 2; i <= j; i++)
        if(n%i == 0)
            return false;
    return true;
}
int main() {
    IOS
    //READ("");
    //WRITE("");
    int n;
    cin>>n;
    // if(is_prime(n-2))cout<<"prime";
    if(!(n%2) || (is_prime(n-2)&& !is_prime(n)))
        cout<<2;
    else {
        (is_prime(n))?cout<<1:cout<<3;
    }
}

#include <bits/stdc++.h>

#define f first
#define s second

#define ll long long
#define ld long double
#define ull unsigned long long

#define pb push_back
#define ppb pop_back
#define mp make_pair

#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define bit(x) __builtin_popcountll(x)
#define sqr(x) ((x) * 1LL * (x))

#define nl '\n'
#define ioi exit(0);

#define NeedForSpeed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define _11day "IOI2017"

using namespace std;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pdd;
typedef pair <ll, ull> hack;

const int N = 1e5 + 7, MxN = 1e6 + 7, mod = 1e9 + 7, inf = 1e9 + 7;
const long long linf = (ll)1e18 + 7;
const long double eps = 1e-15, pi = 3.141592;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

    inline ll Pw(ll a, ll b, ll m) {
        ll res = 1;
        a %= m;
        while (b){
            if (b & 1) res = (res * a) % m, b--;
            a = (a * a) % m,  b >>= 1;
        }
        return res % m;
    }

    inline bool fast(ll d, ll n){
        ll a = 2 + rand() % (n - 4), x = Pw(a, d, n);
        if (x == 1 || x == n - 1) return 1;
        while (d != n - 1){
            x = (x * x) % n, d *= 2;
            if (x == 1) return 0;
            if (x == n - 1) return 1;
        }
        return 0;
    }

    inline bool Check(int n, int k = 100){
        if (n <= 1 || n == 4) return 0;
        if (n <= 3) return 1;

        ll d = n - 1;
        while (d % 2 == 0) d >>= 1;

        for (int i = 1; i <= k; i++)
            if (!fast(d, n)) return 0;
        return 1;
    }

    inline bool Check2(int x){
        if (x < 2) return 0;
        for (int i = 2; i <= sqrt(x); i++)
            if (x % i == 0) return 0;
        return 1;
    }

    inline ll Solve(ll n){
        ll res = 0;
        while (n > 0){
            if (n < 4 || Check(n)){
                res++;
                break;
            }
            for (int i = n - 2; i >= 2; i--)
                if (Check(i)) {n -= i, res++; break;}
        }
        return res;
    }
int main(){
    #ifndef _11day
        freopen (_11day".in", "r", stdin);
        freopen (_11day".out", "w", stdout);
    #endif

    ll n, res = inf, ans = 0;
    cin >> n;
    for (ll i = 1; i <= sqrt(n); i++){
        if (n % i == 0){
            if (Check(n / i)) res = min(res, i);
            if (sqr(i) != n)
                if (Check(n / (n / i))) res = min(res, n / i);
        }
    }
    res = min(res, Solve(n));
    cout << res;
    ioi
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
int haha[44];
bool check(int val) {
    if (val == 7 || val == 5 || val == 3 || val == 2) return true;
//    if ((val + 1) % 6 != 0 && (val - 1) % 6 != 0) return false;
    int end = (int)sqrt(val);
    for (int i = 2; i <= end; ++i) {
        if (val % i == 0) return false;
    }
    return true;
}
int n;
int mx = -inf;
void work() {
    IOS;
    haha[2] = 1;
    haha[3] = 1;
    haha[4] = 2;
    haha[5] = 1;
    haha[6] = 2;
    haha[7] = 1;
    haha[8] = 2;
    haha[9] = 2;
    cin >> n;
    if (n <= 9) {
        cout << haha[n] << endl;
        return;
    }
    if (check(n)) {
        cout << "1" << endl;
        return;
    }
    if (n & 1) {
        cout << "3" << endl;
    } else cout << "2" << endl;
}

int main() {
#ifdef local
    freopen("data.txt","r",stdin);
#endif
    work();
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
main()
{
    int n;
    scanf("%d",&n);
    if(n == 2)
        printf("1");
    else
        if(n%2)
            {
                bool ok=true;
                for(int i = 3;i <= sqrt(n);++i)
                {
                    if(n%i == 0)
                    {   printf("3");
                        ok=false;
                        break;
                    }
                }
                if(ok)
                    printf("1");
            }

        else
            printf("2");
}

#include<bits/stdc++.h>

int main(){

	long long i,n;

	int k=0;

	scanf("%I64d",&n);

	if(n%2==0){

		if(n==2) printf("1\n");

		else printf("2\n");

	}

	else{

		for(i=2;i*i<=n;i++) if((n%i)==0) {k=1; break;}

		if(k==0) printf("1\n");

		else{

			for(i=2;i*i<=n-2;i++) {

				if((n-2)%i==0) {k=1; break;}

				else continue;

			}

			if(k==1) printf("3\n");

			else printf("2\n");

		}

	}

	return 0;

}

#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL m,n,k,p;
int main()
{
	scanf("%lld",&n);
	if (n==2) return printf("1"),0;
	if (n%2LL==0) printf("%d",2);
	else printf("%d",3);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,sum1=0,sum;
    int i,j,k,c,d=0;
    cin>>a>>b;
    k=b;
    for(i=0;i<a;i++){
        cin>>c;
        sum1+=c;
    }
    sum=abs(sum1);
   // cout<<sum;
    if(sum%k==0){
        cout<<sum/k<<endl;
    }
    else if(sum%k!=0){
        cout<<(sum/k)+1<<endl;
    }

}

#include<iostream>
using namespace std;
int n;
int main()
{
    cin>>n;
    if (n%2==0) cout<<2<<endl;
    else
    {
        for (int i=2; i*i<n; i++)
            if (n%i==0)
            {
                cout<<3<<endl;
                return 0;
            }
        cout<<1<<endl;
    }
    return 0;
}

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <ctime>
#include <memory.h>
#include <bitset>
#include <climits>
#include <iomanip>

#define F first
#define S second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define bs 1000000007
#define pi 3.141592653589793
#define y1 kjdfshnvoavaofobiopj
#define ends wieyryrqayreryueyrye
using namespace std;

long long n, save, ans;

long long isprime(long long num)
{
    long long start = 2;
    while(start*start <= num)
    {
        if(num%start == 0)
            return start;
        ++start;
    }
    return 0;
}

int main(){
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);

cin>>n;
save = n;
while(n > 1)
{
    if(!isprime(save) && n-save != 1)
        ++ans, n -= save, save = n+1;
    --save;
}
cout<<ans<<endl;

return 0;}

// In the name of Allah.
// We're nothing and you're everything.
// Ya Ali!

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 14;
bool ispr(int n){
    for(int i = 2; i * i <= n; i++)
        if(n % i == 0)
            return 0;
    return 1;
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    cout << (ispr(n) ? 1 : 2 + n % 2) << '\n';
}