/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		BigInteger bi = new BigInteger(""+n);
		BigInteger bi2 = new BigInteger(""+(n-2));

		if(n == 9) {
		    System.out.println(2);
	    }else if(bi.isProbablePrime(10)) {
	        System.out.println(1);
	    }else {
	        if(n % 2 == 0) System.out.println(2);
	        else{
	            if(bi2.isProbablePrime(10)) {
	                System.out.println(2);
	            }else {
	                System.out.println(3);
	            }
	        }
	    }
	}
}

import java.util.Scanner;

public class Main {
	static long[] dp;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		if (isPrime(n)) {
			System.out.println(1);
		} else if (n % 2 == 0) {
			System.out.println(2);
		} else {
			if(isPrime(n-2)){
				System.out.println(2);
			}else{
				System.out.println(3);
			}
		}
	}

	private static boolean isPrime(long n) {
		if (n == 2)
			return true;
		if (n < 2 || n % 2 == 0)
			return false;
		for (long i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class D735 {
    String filename = "";

    final int INF = 1_000_000_000;
    int gcd (int a, int b){
        return b == 0 ? a : gcd(b, a%b);
    }
    boolean isSimple(int n){
        int d = 2;
        while(d * d <= n){
            if(n % d == 0) return false;
            d++;
        }
        return true;
    }
    void solve() {
        int n =readInt();
        if(isSimple(n)){
            out.print(1);
            return;
        }
        if(n % 2 == 0 || isSimple(n - 2)){
            out.print(2);
            return;
        }
        out.print(3);
    }

    public static void main(String[] args) throws FileNotFoundException {
        new D735().run();
    }

    void run() throws FileNotFoundException {
        init();
        solve();
        out.close();
    }
    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if(!filename.equals("")) {
            in = new BufferedReader(new FileReader(new File(filename + ".in")));
            out = new PrintWriter(new File(filename + ".out"));
            return;
        }

        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    String readLine(){
        try{
            return in.readLine();
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    String readString(){
        while(!tok.hasMoreTokens()){
            String nextLine = readLine();
            if(nextLine == null) return null;
            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt(){
        return Integer.parseInt(readString());
    }

    long readLong(){
        return Long.parseLong(readString());
    }
}

    	 // package codechef; // don't place package name!

    	import java.util.*;
    	import java.lang.*;
    	import java.io.*;

    	/* Name of the class has to be "Main" only if the class is public. */
    	public class Codechef
    	{

    		public static boolean checkprime(int n)
    		{
    		    if(n==2)
    		    return true;

    			int x=(int)Math.ceil(Math.sqrt((double)n));
    			//System.out.println(x);

    			for(int i=2;i<=x;i++)
    				if(n%i==0)
    					return false;

    			return true;
    		}
    		public static void main (String[] args) throws java.lang.Exception
    		{
    			// your code goes here
    			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    			PrintWriter out=new PrintWriter(System.out);

    			int n=Integer.parseInt(br.readLine());

    			if(checkprime(n))
    				out.println(1);
    			else if(n%2==0)
    				out.println(2);
    			else if(checkprime(n-2))
    				out.println(2);
    		    else
    		        out.println(3);

    		    out.close();

    		}
    	}

import java.io.FileNotFoundException;
import java.util.Scanner;

public class B {
    boolean isPrime(long n) {
        for (long i = 3; i * i <= n; i += 2) {
            if (n % i == 0) return false;
        }
        return true;
    }

    public void run() throws FileNotFoundException {
        //Scanner sc = new Scanner(new File("A.txt"));
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        if (n == 2) {
            System.out.println(1);
            return;
        }

        if (n % 2 == 0) {
            System.out.println(2);
            return;
        }

        if (isPrime(n)) {
            System.out.println(1);
            return;
        }

        if (isPrime(n - 2)) {
            System.out.println(2);
            return;
        }

        System.out.println(3);
    }

    public static void main(String[] args) throws FileNotFoundException {
        new B().run();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong();
            if (n < 4) {
                out.println(1);
            } else if (n == 4) {
                out.println(2);
            } else if (n == 5) {
                out.println(1);
            } else if (n == 6) {
                out.println(2);
            } else if (n == 7) {
                out.println(1);
            } else if (n == 9) {
                out.println(2);
            } else {
                if (Prime.test(n)) {
                    out.println(1);
                } else {
                    if (n % 2 == 0) {
                        out.println(2);
                    } else {
                        if (Prime.test(n - 2)) {
                            out.println(2);
                        } else {
                            out.println(3);
                        }
                    }
                }
            }
        }

    }

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in), 32768);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public boolean hasNext() {
            while (st == null || !st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

    static class Prime {
        public static boolean test(long n) {
            for (long i = 2; i * i <= n; i++) {
                if (n % i == 0) return false;
            }
            return true;
        }

    }
}

import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    System.out.println(solve(N));
  }

  static int solve(int N) {
    if (isPrime(N)) return 1;
    if (N % 2 == 0) return 2;
    if (isPrime(N - 2)) return 2;
    return 3;
  }

  static boolean isPrime(int N) {
    if (N == 2) return true;
    if (N % 2 == 0) return false;
    for (long i = 2; i * i <= N; i++) {
      if (N % i == 0) return false;
    }
    return true;
  }

}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;

import java.util.Date;
public class Codeforces {
    public static void main(String[] args) {
  ArrayList A=new ArrayList();
  TreeSet T=new TreeSet();
  Stack S=new Stack();
  Scanner read=new Scanner(System.in);
 StringBuilder str= new StringBuilder();
  ////////////////////////////////////////////
long a=read.nextLong();
if(prime(a))
{
    System.out.println(1);
return;
}
if(a%2==0)
{     System.out.println(2);
return;
}
else
{
    if(prime(a-2))
        System.out.println(2);
    else
        System.out.println(3);
}

    }
static boolean prime(long a)
{
    for(int i=2;i<=Math.sqrt(a);i++)
    {
        if(a%i==0)
            return false;

    }
    return true;
}

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	//static int ans[]=new int[1000001];
		public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		 long n=in.nextLong();
		 if(n==2||n==3||n==5||n==7)
		 {
			 System.out.println(1);
			 System.exit(0);
		 }
		 if(isPrime(n)){
			 System.out.println(1);
			 System.exit(0);
		 }
		 if(isPrime(n-2))
		 {
			 System.out.println(2);
			 System.exit(0);
		 }
		 if(n%2==0)
		 {
			 System.out.println(2);
			 System.exit(0);
		 }
		 if(n%2!=0)
		 {
			 if(isPrime(n))
				 System.out.println(1);
			 else
			 System.out.println(3);
			 System.exit(0);
		 }
		}
		public static boolean isPrime(long 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;
	    }
		public static long pow(long n,long p,long m)
	{
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	}

	static class Pair implements Comparable<Pair>{
		int area;
		int price;
		Pair(int mr,int er){
			area=mr;price=er;
		}
		@Override
		public int compareTo(Pair o) {
			if(o.area>this.area)
				return 1;
			else if(o.area<this.area)
				return -1;
			else
			{
				if(o.price<this.price)
					return 1;
				else
					return -1;
			}
			}
	}
	static class TVF implements Comparable<TVF>{
		int index,size;
		TVF(int i,int c){
			index=i;
			size=c;
		}
		@Override
		public int compareTo(TVF o) {
			if(o.size>this.size)
				return -1;
			else if(o.size<this.size)
				return 1;
			else return 0;
		}
	}
	public static long gcd(long a, long b) {
		  if (b == 0) return a;
		  return gcd(b, a%b);
		}
	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public   int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}

import java.io.*;
import java.util.*;
public class A204
{
    public static void main(String args[])throws IOException
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n%2==0)
        {
            if(n==2)
                System.out.println(1);
            else
                System.out.println(2);
        }
        else
        {
            int c=0;
            for(int i=1;i<=(int)Math.sqrt(n);i++)
            {
                if(n%i==0)
                {
                    c++;
                    if(i!=(n/i))
                        c++;
                }
            }
            if(c==2)
                System.out.println(1);
            else if(n>1)
            {
                n=n-2;c=0;
                for(int i=1;i<=(int)Math.sqrt(n);i++)
                {
                    if(n%i==0)
                    {
                        c++;
                        if(i!=(n/i))
                            c++;
                    }
                }
                if(c==2)
                    System.out.println(2);
                else
                    System.out.println(3);
            }

        }
    }
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		if (n==2) System.out.println(1); else {
			if (n%2==0) System.out.println(2); else {
				boolean b0=true;
				for (int i=2; i<Math.sqrt(n)+1; i++){
					if (n%i==0) b0=false;
				}
				if (b0) System.out.println(1); else{
				int k=n-2;
				boolean b=true;
				for (int i=2; i<(Math.round(Math.sqrt(k))+1); i++){
					if (k%i==0) b=false;
				}
				if (b) System.out.println(2); else System.out.println(3);
				}
			}
		}
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Taxes
{
	public static void main(String args[]) throws Exception
	{
		BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
		int money=Integer.parseInt(f.readLine());
		if(new BigInteger(""+money).isProbablePrime(10))
			System.out.println(1);
		else if(money%2==0)
			System.out.println(2);
		else if(new BigInteger(""+(money-2)).isProbablePrime(10))
			System.out.println(2);
		else
			System.out.println(3);
	}
}

import java.util.Scanner;

public class CF2 {
    static boolean primeValue(int l) {
        for (int i = 2; i * i <= l; i++) {
            if (l % i == 0) {
                return false;
            }
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l;
        l = sc.nextInt();
        if (primeValue(l)){
            System.out.println("1");
        } else if (l % 2 == 0 || primeValue(l-2)){
            System.out.println("2");
        } else {
            System.out.println("3");
        }
    }
}

/**
 * Created by Karan Jobanputra on 31-05-2017.
 */

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class CF3821B {
    public static boolean isPrime(int n)
    {
        if(n==2)
        {
            return true;
        }
        if(n%2 == 0)
        {
            return false;
        }
        for(int i=3;i<=sqrt(n);i+=2)
        {
            if(n%i==0) return false;
        }
        return true;
    }

    public static void main(String args[]) throws Exception {
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        if(isPrime(n))
        {
            pw.println(1);
            pw.close();
            return;
        }
        if(n%2==0)
        {
            pw.println("2");
        }
        else
        if(n%2==1)
        {
            if(isPrime(n-2))
            {
                pw.println(2);
            }
            else
            {
                pw.println(3);
            }
        }

        pw.close();
    }

    static class Node implements Comparable<Node> {
        int v;
        int w;

        Node(int v, int w) {
            this.v = v;
            this.w = w;
        }

        public int compareTo(Node node) {
            if (w == node.w)
                return Integer.compare(v, node.v);

            return (-1) * Integer.compare(w, node.w);
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}

import java.io.*;
import java.util.LinkedList;
import java.util.Objects;
import java.util.StringTokenizer;

public final class Main {

    public void solve() {
        int n = in.nextInt();
        if (Library.isPrime(n)) {
            out.println(1);
        } else {
            if (n % 2 == 0) {
                out.println(2);
            } else if (Library.isPrime(n - 2)) {
                out.println(2);
            } else {
                out.println(3);
            }
        }
    }

    static class Library {
        static boolean isPrime(int a) {
            if (a == 1) {
                return false;
            }
            for (int i = 2; i * i <= a; i++) {
                if (a % i == 0)
                    return false;
            }
            return true;
        }

        static long bpow(long x, long n, long m) {
            long count = 1;
            if (n == 0) {
                return 1;
            }
            while (n > 0) {
                if ((n & 1) == 1) {
                    count *= x;
                    count %= m;
                }
                x *= x;
                x %= m;
                n >>= 1;
            }
            return count % m;
        }

        public long GCD(long a, long b) {
            if (b == 0) return a;
            return GCD(b, a % b);
        }
    }

    class Pair<X, Y> implements Comparable<Pair<X, Y>> {

        public X first;
        public Y second;

        public Pair(X first, Y second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 11 * hash + Objects.hashCode(this.first);
            hash = 11 * hash + Objects.hashCode(this.second);
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Pair<?, ?> other = (Pair<?, ?>) obj;
            if (!Objects.equals(this.first, other.first)) {
                return false;
            }
            if (!Objects.equals(this.second, other.second)) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Pair<X, Y> p) {
            return ((Comparable<X>) first).compareTo(p.first);
        }

        @Override
        public String toString() {
            return first + " " + second;
        }
    }

    class Node<E> {
        E element;
        Node<E> next;
        Node<E> prev;

        Node(E element, Node next, Node prev) {
            this.element = element;
            this.next = next;
            this.prev = prev;
        }
    }

    //    -------------I/O-------------    \\
    private FScanner in;

    private PrintWriter out;

    public static void main(String[] args) {
        new Main().runIO();
    }

    void run() {
        try {
            in = new FScanner(new File("input.txt"));
            out = new PrintWriter(new BufferedWriter(new FileWriter(new File("output.txt"))));
            solve();
            out.close();
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    void runIO() {
        in = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
        in.close();
    }

    class FScanner {

        private BufferedReader br;
        private StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            }
        }

        void useString(String s) {
            if (s != null) {
                st = new StringTokenizer(s);
            }
        }

        void updateST() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

        String next() {
            updateST();
            return st.nextToken();
        }

        Long[] nextLongArray() {
            updateST();
            LinkedList<Long> ll = new LinkedList<>();
            while (st.hasMoreElements()) {
                ll.add(Long.parseLong(st.nextToken()));
            }
            Long[] arr = new Long[1];
            return ll.toArray(arr);
        }

        Integer[] nextIntArray() {
            updateST();
            LinkedList<Integer> ll = new LinkedList<>();
            while (st.hasMoreElements()) {
                ll.add(Integer.parseInt(st.nextToken()));
            }
            Integer[] arr = new Integer[1];
            return ll.toArray(arr);
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            updateST();
            StringBuilder sb = new StringBuilder(st.nextToken());
            while (st.hasMoreElements()) {
                sb.append(st.nextToken());
            }
            return sb.toString();
        }

        void close() {
            try {
                br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Hieu Le
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int income = in.nextInt();
            if (income == 2) {
                out.println(1);
                return;
            }
            // Goldback conjecture.
            if (income % 2 == 0) {
                out.println(2);
                return;
            }

            if (isPrime(income)) {
                out.println(1);
                return;
            }

            if (isPrime(income - 2)) {
                out.println(2);
                return;
            }

            out.println(3);
        }

        private boolean isPrime(int n) {
            if (n == 0 || n == 1)
                return false;
            int limit = (int) Math.sqrt(n);
            for (int i = 2; i <= limit; ++i)
                if (n % i == 0)
                    return false;
            return true;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        private static final int BUFFER_SIZE = 32768;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), BUFFER_SIZE);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.Random;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            BTaxes solver = new BTaxes();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class BTaxes {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            if (LongMillerRabin.mr(n, 10)) {
                out.println(1);
                return;
            }
            if (n == 4) {
                out.println(2);
                return;
            }
            if (n % 2 == 0) {
                out.println(2);
            } else {
                if (LongMillerRabin.mr(n - 2, 10)) {
                    out.println(2);
                } else {
                    out.println(3);
                }
            }
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }

    static interface ILongModular {
        long mul(long a, long b);

        static ILongModular getInstance(long mod) {
            //return new HandyLongModular(mod);
            if (mod <= (1L << 54)) {
                return new LongModularDanger(mod);
            }
            if (mod == (1L << 61) - 1) {
                return LongModular2305843009213693951.getInstance();
            }
            return new HandyLongModular(mod);//new BigLongModular(mod);//new LongModular(mod);
        }

    }

    static class FastInput {
        private final InputStream is;
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

    }

    static class LongModular2305843009213693951 implements ILongModular {
        private static long mod = 2305843009213693951L;
        private static final LongModular2305843009213693951 INSTANCE = new LongModular2305843009213693951();
        private static long mask = (1L << 32) - 1;

        private LongModular2305843009213693951() {
        }

        public static final LongModular2305843009213693951 getInstance() {
            return INSTANCE;
        }

        public long mul(long a, long b) {
            long l1 = DigitUtils.lowBit(a) & mask;
            long h1 = DigitUtils.highBit(a) & mask;
            long l2 = DigitUtils.lowBit(b) & mask;
            long h2 = DigitUtils.highBit(b) & mask;
            long l = l1 * l2;
            long m = l1 * h2 + l2 * h1;
            long h = h1 * h2;
            long ret = (l & mod) + (l >>> 61) + (h << 3) + (m >>> 29) + ((m << 35) >>> 3) + 1;
            ret = (ret & mod) + (ret >>> 61);
            ret = (ret & mod) + (ret >>> 61);
            return ret - 1;
        }

    }

    static class LongPower {
        final ILongModular modular;

        public LongPower(ILongModular modular) {
            this.modular = modular;
        }

        public long pow(long x, long n) {
            if (n == 0) {
                return 1;
            }
            long r = pow(x, n >> 1);
            r = modular.mul(r, r);
            if ((n & 1) == 1) {
                r = modular.mul(r, x);
            }
            return r;
        }

    }

    static class LongModularDanger implements ILongModular {
        final long m;

        public LongModularDanger(long m) {
            this.m = m;
        }

        public long mul(long a, long b) {
            return DigitUtils.modmul(a, b, m);
        }

    }

    static class HandyLongModular implements ILongModular {
        private long mod;
        private long accumulator;
        private static long mask = (1L << 32) - 1;

        public HandyLongModular(long mod) {
            this.mod = mod;
        }

        private void accumulate(long x) {
            for (int i = 63; i >= 0; i -= 4) {
                accumulator = (accumulator << 1) | ((x >> i) & 1);
                if (accumulator >= mod) {
                    accumulator -= mod;
                }
                accumulator = (accumulator << 1) | ((x >> i - 1) & 1);
                if (accumulator >= mod) {
                    accumulator -= mod;
                }
                accumulator = (accumulator << 1) | ((x >> i - 2) & 1);
                if (accumulator >= mod) {
                    accumulator -= mod;
                }
                accumulator = (accumulator << 1) | ((x >> i - 3) & 1);
                if (accumulator >= mod) {
                    accumulator -= mod;
                }
            }
        }

        public long mul(long a, long b) {
            long a0 = a & mask;
            long a1 = (a >>> 32) & mask;
            long b0 = b & mask;
            long b1 = (b >>> 32) & mask;
            long a0b0 = a0 * b0;
            long a0b1 = a0 * b1;
            long a1b0 = a1 * b0;
            long a1b1 = a1 * b1;

            //00
            long d0 = DigitUtils.lowBit(a0b0) & mask;
            long d1 = (DigitUtils.highBit(a0b0) & mask) + (DigitUtils.lowBit(a1b0) & mask) +
                    (DigitUtils.lowBit(a0b1) & mask);
            long d2 = (DigitUtils.highBit(a1b0) & mask) + (DigitUtils.highBit(a0b1) & mask) +
                    (DigitUtils.lowBit(a1b1) & mask) + (DigitUtils.highBit(d1) & mask);
            long d3 = (DigitUtils.highBit(a1b1) & mask) + (DigitUtils.highBit(d2) & mask);
            d2 = DigitUtils.lowBit(d2) & mask;
            d1 = DigitUtils.lowBit(d1) & mask;

            accumulator = 0;
            accumulate((d3 << 32) | d2);
            accumulate((d1 << 32) | d0);
            return accumulator;
        }

    }

    static class LongMillerRabin {
        static ILongModular modular;
        static LongPower power;
        static Random random = new Random();

        public static boolean mr(long n, int s) {
            if (n <= 1) {
                return false;
            }
            if (n == 2) {
                return true;
            }
            if (n % 2 == 0) {
                return false;
            }
            long m = n - 1;
            while (m % 2 == 0) {
                m /= 2;
            }
            modular = ILongModular.getInstance(n);
            power = new LongPower(modular);
            for (int i = 0; i < s; i++) {
                long x = (long) (random.nextDouble() * (n - 2) + 2);
                if (!mr0(x, n, m)) {
                    return false;
                }
            }
            return true;
        }

        private static boolean mr0(long x, long n, long m) {
            return test(power.pow(x, m), m, n);
        }

        private static boolean test(long y, long exp, long n) {
            long y2 = modular.mul(y, y);
            if (!(exp == n - 1 || test(y2, exp * 2, n))) {
                return false;
            }
            if (exp != n - 1 && y2 != 1) {
                return true;
            }
            if (y != 1 && y != n - 1) {
                return false;
            }
            return true;
        }

    }

    static class DigitUtils {
        private DigitUtils() {
        }

        public static long round(double x) {
            if (x >= 0) {
                return (long) (x + 0.5);
            } else {
                return (long) (x - 0.5);
            }
        }

        public static int highBit(long x) {
            return (int) (x >> 32);
        }

        public static int lowBit(long x) {
            return (int) x;
        }

        public static long mod(long x, long mod) {
            x %= mod;
            if (x < 0) {
                x += mod;
            }
            return x;
        }

        public static long modmul(long a, long b, long mod) {
            long k = DigitUtils.round((double) a / mod * b);
            return DigitUtils.mod(a * b - k * mod, mod);
        }

    }
}

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created by Timur on 27.11.2016.
 */
public class _735D {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        if(isPrime(n)){
            System.out.println(1);
            return;
        }
        if(n % 2 == 0 || isPrime(n - 2)) {
            System.out.println(2);
            return;
        }

        System.out.println(3);
        out.close();
    }

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

    public static int check(int n){
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 2; i * i <= n; i++)
            if(n % i == 0){
                list.add(i);
                list.add(n / i);
            }
        if(list.size() == 0)
            return 1;
        else{
            Collections.sort(list);
            return list.get(list.size() - 1);
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.Writer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Nipuna Samarasekara
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    FastScanner in = new FastScanner(inputStream);
    FastPrinter out = new FastPrinter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskB {

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
      int n = in.nextInt();
      if (IntegerUtils.isPrime(n)) {
        out.println(1);
      } else {
        if (n % 2 == 0) {
          out.println(2);
        } else {
          if (IntegerUtils.isPrime(n - 2) || n == 3) {
            out.println(2);
          } else {
            out.println(3);
          }
        }

      }
    }

  }

  static class IntegerUtils {

    public static boolean isPrime(long number) {
      if (number < 2) {
        return false;
      }
      for (long i = 2; i * i <= number; i++) {
        if (number % i == 0) {
          return false;
        }
      }
      return true;
    }

  }

  static class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
      super(out);
    }

    public FastPrinter(Writer out) {
      super(out);
    }

  }

  static class FastScanner extends BufferedReader {

    public FastScanner(InputStream is) {
      super(new InputStreamReader(is));
    }

    public int read() {
      try {
        int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
        return ret;
      } catch (IOException e) {
        throw new InputMismatchException();
      }
    }

    static boolean isWhiteSpace(int c) {
      return c >= 0 && c <= 32;
    }

    public int nextInt() {
      int c = read();
      while (isWhiteSpace(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int ret = 0;
      while (c >= 0 && !isWhiteSpace(c)) {
        if (c < '0' || c > '9') {
          throw new NumberFormatException("digit expected " + (char) c
              + " found");
        }
        ret = ret * 10 + c - '0';
        c = read();
      }
      return ret * sgn;
    }

    public String readLine() {
      try {
        return super.readLine();
      } catch (IOException e) {
        return null;
      }
    }

  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProblemB {
    BufferedReader rd;

    ProblemB() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        long n = plong();
        out(compute(n));
    }

    private long compute(long n) {
        if(isPrime(n)) {
            return 1;
        }
        if(n%2==0) {
            return 2;
        }
        if(isPrime(n-2)) {
            return 2;
        }
        return 3;
    }

    private long plong() throws IOException {
        return plong(rd.readLine());
    }

    private long plong(String s) {
        return Long.parseLong(s);
    }

    private static boolean isPrime(long x) {
        if(x < 4 || x%2 == 0) {
            return x == 2 || x == 3;
        }
        for(long i=3;i*i<=x;i+=2) {
            if(x%i==0) {
                return false;
            }
        }
        return true;
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new ProblemB();
    }
}

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.PrintWriter;
    import java.io.Reader;
    import java.util.Arrays;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Set;
    import java.util.Iterator;
    import java.util.LinkedHashMap;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.StringTokenizer;

    public class Main {

        public static void main(String[] args) {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            InputReader  in = new InputReader (inputStream);
            PrintWriter  out = new PrintWriter (outputStream);
            Main ob = new Main();
            ob.solve(in, out);
            out.close();
            System.exit(0);
        }

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

        void solve(InputReader in, PrintWriter out){
            int n = in.nextInt();
            if(prime(n)) out.println(1);
            else{
                if(n%2==0) out.println(2);
                else{
                    if(prime(n-2)) out.println(2);
                    else out.println(3);
                }
            }
        }

        static class InputReader {
            public BufferedReader reader;
            public StringTokenizer tokenizer;
            public InputReader(InputStream stream) {
                reader = new BufferedReader(new InputStreamReader(stream), 32768);
                tokenizer = null;
            }

            public String next() {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    try {
                        tokenizer = new StringTokenizer(reader.readLine());
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                }
                return tokenizer.nextToken();
            }

            public int nextInt() {
                return Integer.parseInt(next());
            }

            public long nextLong() {
                return Long.parseLong(next());
            }

            public double nextDouble() {
                return Double.parseDouble(next());
            }

            public String nextLine() {
                String str = "";
                try {
                    str = reader.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                return str;
            }
        }
    }

/*
 * Code Author: Akshay Miterani
 * DA-IICT
 */
import java.io.*;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.*;

public class MainA {

	static double eps=(double)1e-6;
	static long mod=(long)1e9+7;
	static final long INF = Long.MAX_VALUE / 100;
	public static void main(String args[]) throws FileNotFoundException{
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		//----------------My Code------------------
		long n=in.nextLong();
		if(isPrime(n)){
			System.out.println("1");
			return;
		}
		if(n%2==0){
			System.out.println("2");
			return;
		}
		long left=n-2;
		if(isPrime(left)){
			System.out.println("2");
		}
		else{
			System.out.println("3");
		}
		out.close();
		//----------------The End------------------

	}
	static boolean isPrime(long x){
		for(int i=2;i<=Math.sqrt(x)+1;i++){
			if(x%i==0 && i!=x)
				return false;
		}
		return true;
	}
	static long modulo(long a,long b,long c) {
		long x=1;
		long y=a;
		while(b > 0){
			if(b%2 == 1){
				x=(x*y)%c;
			}
			y = (y*y)%c; // squaring the base
			b /= 2;
		}
		return  x%c;
	}
	static long gcd(long x, long y)
	{
		if(x==0)
			return y;
		if(y==0)
			return x;
		long r=0, a, b;
		a = (x > y) ? x : y; // a is greater number
		b = (x < y) ? x : y; // b is smaller number
		r = b;
		while(a % b != 0)
		{
			r = a % b;
			a = b;
			b = r;
		}
		return r;
	}
	static class Pair implements Comparable<Pair>{
		int x;
		int y;

		Pair(int xx,int yy){
			x=xx;
			y=yy;
		}
		@Override
		public int compareTo(Pair o) {
			if(Long.compare(this.x, o.x)!=0)
				return Long.compare(this.x, o.x);
			else
				return Long.compare(this.y, o.y);
		}
	}
	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine(){
			String fullLine=null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine=reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}

import java.io.*;
import java.util.*;
public class D
{
    private static boolean isPrime(int N)
    {
        int i;

        for(i=2;i<=(int)Math.sqrt(N);i++)
            if(N%i==0)
                return false;
        return true;
    }
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int N;

        N=Integer.parseInt(br.readLine().trim());

        if(isPrime(N))
            System.out.println(1);
        else if(N%2==0||isPrime(N-2))
            System.out.println(2);
        else
            System.out.println(3);
    }
}

/*
 * Author Ayub Subhaniya
 * Institute DA-IICT
 */

import java.io.*;
import java.math.*;
import java.util.*;

public class JuneLong{

	InputStream in;
	PrintWriter out;

	void solve() {
		int n=ni();
		boolean flag=true;
		for (int i=2;i*i<=n;i++)
		{
			if (n%i==0)
			{
				flag=false;
				break;
			}
		}
		if (flag)
			out.println(1);
		else if(n%2==1)
		{
			n-=2;
			flag=true;
			for (int i=2;i*i<=n;i++)
			{
				if (n%i==0)
				{
					flag=false;
					break;
				}
			}
			if (flag)
				out.println(2);
			else
				out.println(3);
		}
		else
			out.println(2);
	}

	class Merge {

		void sort(int inputArr[]) {
			int length = inputArr.length;
			doMergeSort(inputArr, 0, length - 1);
		}

		void doMergeSort(int[] arr, int lowerIndex, int higherIndex) {
			if (lowerIndex < higherIndex) {
				int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
				doMergeSort(arr, lowerIndex, middle);
				doMergeSort(arr, middle + 1, higherIndex);
				mergeParts(arr, lowerIndex, middle, higherIndex);
			}
		}

		void mergeParts(int[] array, int lowerIndex, int middle, int higherIndex) {
			int[] temp = new int[higherIndex - lowerIndex + 1];
			for (int i = lowerIndex; i <= higherIndex; i++) {
				temp[i - lowerIndex] = array[i];
			}
			int i = lowerIndex;
			int j = middle + 1;
			int k = lowerIndex;
			while (i <= middle && j <= higherIndex) {
				if (temp[i - lowerIndex] < temp[j - lowerIndex]) {
					array[k] = temp[i - lowerIndex];
					i++;
				} else {
					array[k] = temp[j - lowerIndex];
					j++;
				}
				k++;
			}
			while (i <= middle) {
				array[k] = temp[i - lowerIndex];
				k++;
				i++;
			}
			while (j <= higherIndex) {
				array[k] = temp[j - lowerIndex];
				k++;
				j++;
			}
		}

	}

	void run() throws Exception {
		String INPUT = "C:/Users/ayubs/Desktop/input.txt";
		in = oj ? System.in : new FileInputStream(INPUT);
		out = new PrintWriter(System.out);

			long s = System.currentTimeMillis();
			solve();
			out.flush();
			tr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {
		new JuneLong().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean inSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && inSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(inSpaceChar(b))) { // when nextLine, (inSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(inSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

}

import java.io.*;
import java.util.*;

public class B {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);

		long n = Long.parseLong(in.readLine());

		if (isPrime(n)) {
			out.println(1);
		} else {
			if (n % 2 == 0) {
				out.println(2);
			} else {
				if (isPrime(n - 2)) {
					out.println(2);
				} else {
					out.println(3);
				}
			}
		}

		in.close();
		out.close();
	}

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

import java.math.BigInteger;
import java.util.Scanner;

public class D735 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int m = sc.nextInt();
		BigInteger b = new BigInteger(m+"");

		if (b.isProbablePrime(100)) {
			System.out.println(1);
		}else if (m%2==0) {
			System.out.println(2);
		}else if (b.subtract(BigInteger.valueOf(2)).isProbablePrime(100)) {
			System.out.println(2);
		}else {
			System.out.println(3);
		}

	}

}

import java.util.*;

public class main {
    static int woof(int n)
    {
        if(primecheck(n))return 1;
        if (n % 2 == 0||primecheck(n-2)) return 2;
        return 3;
    }

    static boolean primecheck(int n) {
        for (int i = 2;i * i <= n; i++) {
            if (n % i == 0)
                return false; }
        return true;
    }
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        System.out.println(woof(n));
    }

}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
  static boolean prime (int n) {
    for (int i = 2; i * i <= n; i++)
      if (n % i == 0)
        return false;
	return true;
  }
	public static void main (String[] args) throws java.lang.Exception
	{
	  Scanner in = new Scanner(System.in);
	   int n = in.nextInt();
	    if (prime(n) == true)
	  	  System.out.println("1");
	    else {
		  if (n % 2 == 0)
		    System.out.println("2");
		  else {
		    if ( n % 2 == 1 && prime(n - 2) == true)
		      System.out.println("2");
			else
			  System.out.println("3");
		  }
	    }
	}
}

import java.io.*;
import java.util.*;
public class Taxes {
    public static void main(String[] args) {
        PrintWriter pr = new PrintWriter(System.out);
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        if(isPrime(n)){
            System.out.println(1);
            return;
        }
        if(n%2==0 || isPrime(n-2)){
            System.out.println(2);
        }
        else{
            System.out.println(3);
        }

    }
    public static boolean isPrime(long n){
        for(long i=2;i*i<=n;i++){
            if(n%i==0)
                return false;
        }
        return true;
    }
}

import java.io.*;
import java.util.*;
//import java.Math.*;

public class cf382div2B{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int i,j,k;

		int n=in.nextInt();
		//int m=in.nextInt();

		if(n==1||n==2||n==3||n==5||n==7){
			System.out.println("1");
		}else if(cf382div2B.isPrime(n)){
			System.out.println("1");
		}else if(cf382div2B.isPrime(n-2)){
			System.out.println("2");
		}else if(n%2==0){
			System.out.println("2");
		}else {
			System.out.println("3");
		}

//			System.out.println(isPrime(n));

	 }

	public static boolean isPrime(int N){
		for (int i = 2; i<=Math.sqrt(N); ++i)
		{
			if(N%i==0)
				return false;
		}
		return true;
	}

}

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class CodeB {
  private static final boolean SHOULD_BUFFER_OUTPUT = false;

  static final SuperWriter sw = new SuperWriter(System.out);

  static final SuperScanner sc = new SuperScanner();

  static class PrimeTester {
    static long mulMod(long a, long b, long n) {
      if(a == 0 || b <= (1L << 62) / a) return (a * b) % n;
      long result = 0;
      if(a < b) { long tmp = a; a = b; b = tmp; }
      for(; b != 0; b >>= 1) {
        if((b & 1) != 0) {
          result += a; if(result >= n) result -= n;
        }
        a <<= 1; if(a >= n) a -= n;
      }
      return result;
    }

    static long gcd(long u, long v) {
      while(u != 0){v %= u; long tmp = u; u = v; v = tmp;} return v;
    }

    static long f(long x, long c, long n) {
      long result = mulMod(x, x, n);
      result += c; if(result >= n) result -= n;
      return result;
    }

    static long pollardsRho(long n) {
      for (int count = 0, c = 1;;) {
        long x = 2, y = 2, pot = 1, lam = 1, d;
        do {
          ++count;
          if(pot == lam) {x = y; pot <<= 1; lam = 0;}
          y = f(y,c,n);
          lam++;
          d = gcd(x >= y ? x - y : y - x, n);
        } while (d == 1);
        if (d != n) return d; else c++;
      }
    }

    static long powMod(long a, long exp, long n) {
      long result = 1;
      for(; exp != 0; exp >>= 1) {
        if((exp & 1) != 0) {
          result = mulMod(result, a, n);
        }
        a = mulMod(a, a, n);
      }
      return result;
    }

    static boolean primeTestMillerRabin(long n, long a) {
      long d = n-1, x;
      int s = 0, r;
      while ((d & 1) == 0 && d != 0){ s++; d >>= 1;}
      while (a >= n) a >>= 1;
      x = powMod(a, d, n);
      if (x != 1 && x != n-1) {
        r = 1;
        while (r <= s-1 && x != n-1) {
          x = mulMod(x, x, n);
          if (x == 1) return false; else r++;
        }
        if (x != n-1) return false;
      }
      return true;
    }

    static boolean isPrime(long n) {
      if (n <= 1) return false;
      if (n <= 3) return true;
      if ((n & 1) == 0) return false;
      return primeTestMillerRabin(n, 2) && primeTestMillerRabin(n, 3)
      && primeTestMillerRabin(n, 5) && primeTestMillerRabin(n, 7)
      && (n < 3215031751L || (primeTestMillerRabin(n, 11)
      && (n < 2152302898747L || (primeTestMillerRabin(n, 13)
      && (n < 3474749660383L || (primeTestMillerRabin(n, 17)
      && (n < 341550071728321L || (primeTestMillerRabin(n, 23)))))))));
    }
  }

  static class DivisorGenerator {
    static long mulMod(long a, long b, long n) {
      if(a == 0 || b <= (1L << 62) / a) return (a * b) % n;
      long result = 0;
      if(a < b) { long tmp = a; a = b; b = tmp; }
      for(; b != 0; b >>= 1) {
        if((b & 1) != 0) {
          result += a; if(result >= n) result -= n;
        }
        a <<= 1; if(a >= n) a -= n;
      }
      return result;
    }

    static long gcd(long u, long v) {
      while(u != 0){v %= u; long tmp = u; u = v; v = tmp;} return v;
    }

    static long f(long x, long c, long n) {
      long result = mulMod(x, x, n);
      result += c; if(result >= n) result -= n;
      return result;
    }

    static long pollardsRho(long n) {
      for (int count = 0, c = 1;;) {
        long x = 2, y = 2, pot = 1, lam = 1, d;
        do {
          ++count;
          if(pot == lam) {x = y; pot <<= 1; lam = 0;}
          y = f(y,c,n);
          lam++;
          d = gcd(x >= y ? x - y : y - x, n);
        } while (d == 1);
        if (d != n) return d; else c++;
      }
    }

    static long powMod(long a, long exp, long n) {
      long result = 1;
      for(; exp != 0; exp >>= 1) {
        if((exp & 1) != 0) {
          result = mulMod(result, a, n);
        }
        a = mulMod(a, a, n);
      }
      return result;
    }

    static boolean primeTestMillerRabin(long n, long a) {
      long d = n-1, x;
      int s = 0, r;
      while ((d & 1) == 0 && d != 0){ s++; d >>= 1;}
      while (a >= n) a >>= 1;
      x = powMod(a, d, n);
      if (x != 1 && x != n-1) {
        r = 1;
        while (r <= s-1 && x != n-1) {
          x = mulMod(x, x, n);
          if (x == 1) return false; else r++;
        }
        if (x != n-1) return false;
      }
      return true;
    }

    static boolean isPrime(long n) {
      if (n <= 1) return false;
      if (n <= 3) return true;
      if ((n & 1) == 0) return false;
      return primeTestMillerRabin(n, 2) && primeTestMillerRabin(n, 3)
      && primeTestMillerRabin(n, 5) && primeTestMillerRabin(n, 7)
      && (n < 3215031751L || (primeTestMillerRabin(n, 11)
      && (n < 2152302898747L || (primeTestMillerRabin(n, 13)
      && (n < 3474749660383L || (primeTestMillerRabin(n, 17)
      && (n < 341550071728321L || (primeTestMillerRabin(n, 23)))))))));
    }

    static void factorize(long n, Map <Long, Integer> all)
    {
      if(n == 1)
        return;
      if(isPrime(n))
      {
        if(all.containsKey(n))
          all.put(n, all.get(n) + 1);
        else
          all.put(n, 1);
      }
      else
      {
        long fact = pollardsRho(n);
        factorize(fact, all);
        factorize(n / fact, all);
      }
    }
  }

  public static void main() {
    long n = sc.nextLong();
    if (n == 4) {
      sw.printLine(2);
    } else {
      if (DivisorGenerator.isPrime(n)) {
        sw.printLine(1);
      } else {
        if ((n & 1) == 0) {
          sw.printLine(2);
        } else {
          if (DivisorGenerator.isPrime(n - 2)) {
            sw.printLine(2);
          } else {
            sw.printLine(3);
          }
        }
      }
    }
  }

  static class LineScanner extends Scanner {
    private StringTokenizer st;

    public LineScanner(String input) {
      st = new StringTokenizer(input);
    }

    @Override
    public String next() {
      return st.hasMoreTokens() ? st.nextToken() : null;
    }

    @Override
    public String nextLine() {
      throw new RuntimeException("not supported");
    }

    public boolean hasNext() {
      return st.hasMoreTokens();
    }

    private final ArrayList<Object> temp = new ArrayList<Object>();

    private void fillTemp() {
      while (st.hasMoreTokens()) {
        temp.add(st.nextToken());
      }
    }

    public String[] asStringArray() {
      fillTemp();
      String[] answer = new String[temp.size()];
      for (int i = 0; i < answer.length; i++) {
        answer[i] = (String) temp.get(i);
      }
      temp.clear();
      return answer;
    }

    public int[] asIntArray() {
      fillTemp();
      int[] answer = new int[temp.size()];
      for (int i = 0; i < answer.length; i++) {
        answer[i] = Integer.parseInt((String) temp.get(i));
      }
      temp.clear();
      return answer;
    }

    public long[] asLongArray() {
      fillTemp();
      long[] answer = new long[temp.size()];
      for (int i = 0; i < answer.length; i++) {
        answer[i] = Long.parseLong((String) temp.get(i));
      }
      temp.clear();
      return answer;
    }

    public double[] asDoubleArray() {
      fillTemp();
      double[] answer = new double[temp.size()];
      for (int i = 0; i < answer.length; i++) {
        answer[i] = Double.parseDouble((String) temp.get(i));
      }
      temp.clear();
      return answer;
    }
  }

  static class SuperScanner extends Scanner {
    private InputStream stream;
    private byte[] buf = new byte[8096];
    private int curChar;
    private int numChars;

    public SuperScanner() {
        this.stream = System.in;
    }

    public int read() {
        if (numChars == -1)
            return -1;
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public static boolean isLineEnd(int c) {
      return c == '\n' || c == -1;
    }

    private final StringBuilder sb = new StringBuilder();

    @Override
    public String next() {
      int c = read();
      while (isWhitespace(c)) {
          if (c == -1) {
            return null;
          }
          c = read();
      }
      sb.setLength(0);
      do {
          sb.append((char) c);
          c = read();
      } while (!isWhitespace(c));
      return sb.toString();
    }

    @Override
    public String nextLine() {
      sb.setLength(0);
      int c;
      while (true) {
        c = read();
        if (!isLineEnd(c)) {
          sb.append((char) c);
        } else {
          break;
        }
      }
      if (c == -1 && sb.length() == 0) {
        return null;
      } else {
        if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '\r') {
          return sb.substring(0, sb.length() - 1);
        } else {
          return sb.toString();
        }
      }
    }

    public LineScanner nextLineScanner() {
      String line = nextLine();
      if (line == null) {
        return null;
      } else {
        return new LineScanner(line);
      }
    }

    public LineScanner nextNonEmptyLineScanner() {
      while (true) {
        String line = nextLine();
        if (line == null) {
          return null;
        } else if (!line.isEmpty()) {
          return new LineScanner(line);
        }
      }
    }

    @Override
    public int nextInt() {
        int c = read();
        while (isWhitespace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res = (res << 3) + (res << 1);
            res += c - '0';
            c = read();
        } while (!isWhitespace(c));
        return res * sgn;
    }

    @Override
    public long nextLong() {
        int c = read();
        while (isWhitespace(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res = (res << 3) + (res << 1);
            res += c - '0';
            c = read();
        } while (!isWhitespace(c));
        return res * sgn;
    }
  }

  static abstract class Scanner {

    public abstract String next();

    public abstract String nextLine();

    public int nextIntOrQuit() {
      Integer n = nextInteger();
      if (n == null) {
        sw.close();
        System.exit(0);
      }
      return n.intValue();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] res = new int[n];
      for (int i = 0; i < res.length; i++)
        res[i] = nextInt();
      return res;
    }

    public long[] nextLongArray(int n) {
      long[] res = new long[n];
      for (int i = 0; i < res.length; i++)
        res[i] = nextLong();
      return res;
    }

    public double[] nextDoubleArray(int n) {
      double[] res = new double[n];
      for (int i = 0; i < res.length; i++)
        res[i] = nextDouble();
      return res;
    }

    public void sortIntArray(int[] array) {
      Integer[] vals = new Integer[array.length];
      for (int i = 0; i < array.length; i++)
        vals[i] = array[i];
      Arrays.sort(vals);
      for (int i = 0; i < array.length; i++)
        array[i] = vals[i];
    }

    public void sortLongArray(long[] array) {
      Long[] vals = new Long[array.length];
      for (int i = 0; i < array.length; i++)
        vals[i] = array[i];
      Arrays.sort(vals);
      for (int i = 0; i < array.length; i++)
        array[i] = vals[i];
    }

    public void sortDoubleArray(double[] array) {
      Double[] vals = new Double[array.length];
      for (int i = 0; i < array.length; i++)
        vals[i] = array[i];
      Arrays.sort(vals);
      for (int i = 0; i < array.length; i++)
        array[i] = vals[i];
    }

    public String[] nextStringArray(int n) {
      String[] vals = new String[n];
      for (int i = 0; i < n; i++)
        vals[i] = next();
      return vals;
    }

    public Integer nextInteger() {
      String s = next();
      if (s == null)
        return null;
      return Integer.parseInt(s);
    }

    public int[][] nextIntMatrix(int n, int m) {
      int[][] ans = new int[n][];
      for (int i = 0; i < n; i++)
        ans[i] = nextIntArray(m);
      return ans;
    }

    public char[][] nextGrid(int r) {
      char[][] grid = new char[r][];
      for (int i = 0; i < r; i++)
        grid[i] = next().toCharArray();
      return grid;
    }

    public static <T> T fill(T arreglo, int val) {
      if (arreglo instanceof Object[]) {
        Object[] a = (Object[]) arreglo;
        for (Object x : a)
          fill(x, val);
      } else if (arreglo instanceof int[])
        Arrays.fill((int[]) arreglo, val);
      else if (arreglo instanceof double[])
        Arrays.fill((double[]) arreglo, val);
      else if (arreglo instanceof long[])
        Arrays.fill((long[]) arreglo, val);
      return arreglo;
    }

    public <T> T[] nextObjectArray(Class<T> clazz, int size) {
      @SuppressWarnings("unchecked")
      T[] result = (T[]) java.lang.reflect.Array.newInstance(clazz, size);
      for (int c = 0; c < 3; c++) {
        Constructor<T> constructor;
        try {
          if (c == 0)
            constructor = clazz.getDeclaredConstructor(Scanner.class,
                Integer.TYPE);
          else if (c == 1)
            constructor = clazz.getDeclaredConstructor(Scanner.class);
          else
            constructor = clazz.getDeclaredConstructor();
        } catch (Exception e) {
          continue;
        }
        try {
          for (int i = 0; i < result.length; i++) {
            if (c == 0)
              result[i] = constructor.newInstance(this, i);
            else if (c == 1)
              result[i] = constructor.newInstance(this);
            else
              result[i] = constructor.newInstance();
          }
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
        return result;
      }
      throw new RuntimeException("Constructor not found");
    }

    public Collection<Integer> wrap(int[] as) {
      ArrayList<Integer> ans = new ArrayList<Integer>();
      for (int i : as)
        ans.add(i);
      return ans;
    }

    public int[] unwrap(Collection<Integer> collection) {
      int[] vals = new int[collection.size()];
      int index = 0;
      for (int i : collection)
        vals[index++] = i;
      return vals;
    }

    int testCases = Integer.MIN_VALUE;

    boolean testCases() {
      if (testCases == Integer.MIN_VALUE) {
        testCases = nextInt();
      }
      return --testCases >= 0;
    }
  }

  static class SuperWriter {

    private final PrintWriter writer;

    public SuperWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public SuperWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void close() {
        writer.flush();
        writer.close();
    }

    public void printLine(String line) {
      writer.println(line);
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public void printLine(int... vals) {
      if (vals.length == 0) {
        writer.println();
      } else {
        writer.print(vals[0]);
        for (int i = 1; i < vals.length; i++)
          writer.print(" ".concat(String.valueOf(vals[i])));
        writer.println();
      }
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public void printLine(long... vals) {
      if (vals.length == 0) {
        writer.println();
      } else {
        writer.print(vals[0]);
        for (int i = 1; i < vals.length; i++)
          writer.print(" ".concat(String.valueOf(vals[i])));
        writer.println();
      }
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public void printLine(double... vals) {
      if (vals.length == 0) {
        writer.println();
      } else {
        writer.print(vals[0]);
        for (int i = 1; i < vals.length; i++)
          writer.print(" ".concat(String.valueOf(vals[i])));
        writer.println();
      }
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public void printLine(int prec, double... vals) {
      if (vals.length == 0) {
        writer.println();
      } else {
        String precision = "%." + prec + "f";
        writer.print(String.format(precision, vals[0]).replace(',', '.'));
        precision = " " + precision;
        for (int i = 1; i < vals.length; i++)
          writer.print(String.format(precision, vals[i]).replace(',', '.'));
        writer.println();
      }
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public <E> void printLine(Collection<E> vals) {
      if (vals.size() == 0) {
        writer.println();
      } else {
        int i = 0;
        for (E val : vals) {
          if (i++ == 0) {
            writer.print(val.toString());
          } else {
            writer.print(" ".concat(val.toString()));
          }
        }
        writer.println();
      }
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public void printSimple(String value) {
      writer.print(value);
      if (!SHOULD_BUFFER_OUTPUT) {
        writer.flush();
      }
    }

    public boolean ifZeroExit(Number... values) {
    	for (Number number : values) {
    		if (number.doubleValue() != 0.0d || number.longValue() != 0) {
    			return false;
    		}
    	}
    	close();
    	System.exit(0);
    	return true;
    }
  }

  public static void main(String[] args) {
    main();
    sw.close();
  }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.Writer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Niyaz Nigmatullin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, FastPrinter out) {
            long n = in.nextInt();
            boolean isPrime = isPrime(n);
            if (isPrime) {
                out.println(1);
                return;
            }
            if ((n & 1) == 0) {
                out.println(2);
                return;
            }
            if (isPrime(n - 2)) {
                out.println(2);
                return;
            }
            out.println(3);
        }

        private boolean isPrime(long n) {
            boolean isPrime = true;
            for (long i = 2; i * i <= n; i++) {
                if (n % i == 0) {
                    isPrime = false;
                    break;
                }
            }
            return isPrime;
        }

    }

    static class FastPrinter extends PrintWriter {
        public FastPrinter(OutputStream out) {
            super(out);
        }

        public FastPrinter(Writer out) {
            super(out);
        }

    }

    static class FastScanner extends BufferedReader {
        public FastScanner(InputStream is) {
            super(new InputStreamReader(is));
        }

        public int read() {
            try {
                int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
                return ret;
            } catch (IOException e) {
                throw new InputMismatchException();
            }
        }

        static boolean isWhiteSpace(int c) {
            return c >= 0 && c <= 32;
        }

        public int nextInt() {
            int c = read();
            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new NumberFormatException("digit expected " + (char) c
                            + " found");
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        }

        public String readLine() {
            try {
                return super.readLine();
            } catch (IOException e) {
                return null;
            }
        }

    }
}

import java.awt.*;
import java.io.*;
import java.util.*;

public class Abc {
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        FastReader sc=new FastReader();
        int n=sc.nextInt();
        if (p(n)){
            System.out.println(1);
            return;
        }

        if (n%2==0){
            System.out.println(2);
        }else {
            if (p(n-2)){
                System.out.println(2);
                return;
            }
            System.out.println(3);
        }
    }
    static boolean p(int n){
        if (n==2)return true;
        for (int i=2;i*i<=n;i++){
            if (n%i==0)return false;
        }

        return true;
    }
    static boolean t2(int n){
        int c=0;
        for (int i=2;i*i<=n;i++){
            if (n%i==0){
                while (n%i==0){
                    n/=i;
                    c++;
                }
            }
        }
        return c==2;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

import java.util.*;
public class TaxProblem {

	static long num;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);

		num = scan.nextLong();

		if(num==2) {
			System.out.println(1);
		}else if(num%2==0){
			System.out.println(2);
		}else if(isPrime(num)){
			System.out.println(1);
		}else if(isPrime(num-2)){
			System.out.println(2);
		}else{
			System.out.println(3);
		}

	}

	public static boolean isPrime(long num){
		for(long i=2;i<=(long)Math.sqrt(num);i++){
			if(num%i==0){
				return false;
			}
		}
		return true;
	}

}

import java.util.*;
import java.math.*;
import java.io.*;
public class Taxes {
	static class Reader {
			final private int BUFFER_SIZE = 1 << 16;
			private DataInputStream din;
			private byte[] buffer;
			private int bufferPointer, bytesRead;
			public Reader() {
				din = new DataInputStream(System.in);
				buffer = new byte[BUFFER_SIZE];
				bufferPointer = bytesRead = 0;
			}
			public Reader(String file_name) throws IOException {
				din = new DataInputStream(new FileInputStream(file_name));
				buffer = new byte[BUFFER_SIZE];
				bufferPointer = bytesRead = 0;
			}
			public String readLine() throws IOException {
				byte[] buf = new byte[64]; // line length
				int cnt = 0, c;
				while ((c = read()) != -1) {
					if (c == '\n')
						break;
					buf[cnt++] = (byte) c;
				}
				return new String(buf, 0, cnt);
			}
			public int nextInt() throws IOException {
				int ret = 0;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do {
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
				if (neg)
					return -ret;
				return ret;
			}
			public long nextLong() throws IOException {
				long ret = 0;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do {
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
				if (neg)
					return -ret;
				return ret;
			}
			public double nextDouble() throws IOException {
				double ret = 0, div = 1;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do {
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
				if (c == '.') {
					while ((c = read()) >= '0' && c <= '9') {
						ret += (c - '0') / (div *= 10);
					}
				}
				if (neg)
					return -ret;
				return ret;
			}
			private void fillBuffer() throws IOException {
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
				if (bytesRead == -1)
					buffer[0] = -1;
			}
			private byte read() throws IOException {
				if (bufferPointer == bytesRead)
					fillBuffer();
				return buffer[bufferPointer++];
			}
			public void close() throws IOException {
				if (din == null)
					return;
				din.close();
			}
		}
	public static void main(String args[]) throws Exception {
		Reader s = new Reader();
		long n = s.nextLong();
		BigInteger x = new BigInteger(String.valueOf(n));
		if(x.isProbablePrime(20))System.out.println(1);
		else if(x.mod(new BigInteger("2")) == BigInteger.ZERO || x.subtract(new BigInteger("2")).isProbablePrime(20))System.out.println(2);
		else if(x.longValue() > 6)System.out.println(3);
	}
}

////////////////////---------------------------SHUBHAM CHAUDHARI-------------------------------///////////////////////

import java.net.Inet4Address;
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        if(isPrime(n))
            System.out.println(1);
        else if(n%2==0||isPossible(n))
            System.out.println(2);
        else
            System.out.println(3);
    }
    static boolean isPrime(int n)
    {
        if (n <= 1)
            return false;

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0)
                return false;
        }

        return true;
    }

    static boolean isPossible(int N)
    {
        if (isPrime(N - 2))
            return true;
        else
            return false;
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			long n = in.nextLong();
			long ans = 3; // Goldbach's weak conjecture.
			if (n == 2) {
				ans = 1;
			} else if (n % 2 == 0) {
				ans = 2; // Goldbach's conjecture.
			} else if (isOddPrime(n)) {
				ans = 1;
			} else if (isOddPrime(n - 2)) {
				ans = 2;
			}
			out.println(ans);
		}

		private boolean isOddPrime(long n) {
			if (n < 3) {
				return false;
			}
			for (long d = 2; d * d <= n && d < n; d++) {
				if (n % d == 0) {
					return false;
				}
			}
			return true;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}

//package round382;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		if(n % 2 == 0){
			if(n == 2){
				out.println(1);
			}else{
				out.println(2);
			}
		}else{
			if(BigInteger.valueOf(n).isProbablePrime(40)){
				out.println(1);
			}else{
				int m = n-2;
				if(BigInteger.valueOf(m).isProbablePrime(40)){
					out.println(2);
				}else{
					out.println(3);
				}
			}
		}
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new B().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long N = in.nextLong();

        if(N >= 4 && N % 2 == 0){
            System.out.println(2);
            return;
        }

        if(new BigInteger(Long.toString(N)).isProbablePrime(10) || N <= 3){
            System.out.println(1);
            return;
        }

        if( new BigInteger(Long.toString(N-2)).isProbablePrime(10) ||
               N <= 9){
            System.out.println(2);
            return;
        }

        if(N > 9 && N % 2 == 1)
        {
            System.out.println(3);
            return;
        }

    }
}

import java.util.Scanner;

/**
 * Created by kirillskiy on 27/11/2016.
 */
public class Nalog {

    public static class Pair<T1, T2> {

        private final T1 t1;
        private final T2 t2;

        public Pair(T1 t1, T2 t2) {
            this.t1 = t1;
            this.t2 = t2;
        }

        public T1 getT1() {
            return t1;
        }

        public T2 getT2() {
            return t2;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            Pair pair = (Pair) o;
            return t1.equals(pair.t1) && t2.equals(pair.t2);
        }

        @Override
        public int hashCode() {
            int result = t1.hashCode();
            result = 31 * result + t2.hashCode();
            return result;
        }

    }

    static boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    private static int findNextPrime(int n) {
        if (isPrime(n)) {
            return n;
        }
        return findNextPrime(n - 1);
    }

    private static int result = -1;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String nS = scanner.next();
        int n = Integer.parseInt(nS);

        int startingPrime = isPrime(n) ? n : findNextPrime(n);

        System.out.println(getNalog(n, startingPrime, 0).getT2());
    }

    //left sum + nalog parts
    private static Pair<Integer, Integer> getNalog(int n, int maxPrime, int nalogParts) {

        if (n < 0) {
            return null;
        }
        if (isPrime(n)) {
            return new Pair<>(0, 1 + nalogParts);
        }

        if (n == 0) {
            return new Pair<>(0, nalogParts);
        }

        if (n % 2 == 0) {
            return new Pair<>(0, 2 + nalogParts);
        }

        Pair<Integer, Integer> option1 = getNalog(n - maxPrime, maxPrime, nalogParts + 1);
        Pair<Integer, Integer> option2 = getNalog(n - maxPrime, findNextPrime(n), nalogParts + 1);

        if (option1 != null && option1.getT1() == 0 && option2 != null && option2.getT1() == 0) {
            return new Pair<>(0, Math.min(option1.getT2(), option2.getT2()));
        }

        if (option1 == null && option2 != null && option2.getT1() == 0) {
            return option2;
        }

        if (option2 == null && option1 != null && option1.getT1() == 0) {
            return option1;
        }

        return null;
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            if (BigInteger.valueOf(n).isProbablePrime(100)) {
                out.println(1);
            } else if (n % 2 == 0) {
                out.println(2);
                return;
            } else {
                if (BigInteger.valueOf(n - 2).isProbablePrime(100))
                    out.println(2);
                else
                    out.println(3);
                return;
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

//Fig 3: B.Taxes.java
import java.util.Scanner;
public class Taxes {
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		if(control(n)){
			System.out.print("1");
		}
		else if(n%2==0 || control(n-2)){
			 System.out.print("2");
		}
		else{
			System.out.print("3");
		}

		input.close();
	}
	public static Boolean control(int n){
		for(int i=2;i*i<=n;i++)
			if(n%i==0)
				return false;
				return true;

	}

}

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class D {
	public static ArrayList<Long> primes() {
		ArrayList<Long> primes = new ArrayList<Long>();
		primes.add(2L);
		for(long i=3; i<50000; i+=2) {
			boolean isPrime = true;
			for(int k=0; k<primes.size(); k++){
				if(i % primes.get(k) == 0) {
					isPrime = false;
					break;
				}
				if(i < primes.get(k)*primes.get(k)) break;
			}
			if(isPrime) primes.add((long)i);
		}
		return primes;
	}

	public static boolean isPrime(long n) {
		ArrayList<Long> list = primes();
		for(int i=0; i<list.size(); i++) {
			if(n < list.get(i)*list.get(i)) return true;
			if(n % list.get(i) == 0) return false;
		}
		return true;
	}

	public static void main(String[] args) {
		FS r = new FS();
		long n = r.nextLong();
		if(isPrime(n)) {
			System.out.println(1);
			return;
		} else if(n%2==0) {
			System.out.println(2);
		} else if(isPrime(n-2)) {
			System.out.println(2);
		} else {
			System.out.println(3);
		}
	}

	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}

		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        if (isPrime(n)) out.println(1);
        else if (n % 2 == 0 || isPrime(n - 2)) out.println(2);
        else out.println(3);
        out.flush();
        out.close();
    }

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

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

    }

}

import java.io.*;

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine()),ans=0;
        if(n%2==0)
        {
            if(n==2) ans=1;
            else ans=2; //Goldbach's conjecture
        }
        else
        {
            if(prime(n)) ans=1;
            else if(prime(n-2)) ans=2;
            else ans=3;
        }
        System.out.print(ans);
    }

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

import java.util.Scanner;
public class Taxes{
	public static int computeMinPay(int n){
		if(isPrime(n) == true)
		    return 1;
		if(n % 2 == 1 && n > 20){
		    if(isPrime(n-2) == true && n > 20)
			    return 2;
			return 3;
		}
		return 2;
	}
	public static boolean isPrime(int n){
	    int sqrt = (int)Math.sqrt(n) + 1;
		for(int i = 2; i < sqrt; i++){
			if(n % i == 0)
			    return false;
		}
		return true;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(computeMinPay(n));
	}
}

import java.util.*;
public class Main{
    static boolean isPrime(int n){
        for (int i = 3; i * i <= n; i++){
            if (n % i == 0) return false;
        }
        return true;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 3) System.out.println(1);
        else if (n % 2 == 0){
            if (n == 2) System.out.println(1);
            else System.out.println(2);
            System.exit(0);
        }
        else if (isPrime(n)) System.out.println(1);
        else if (isPrime(n-2)){
            System.out.println(2);
        }
        else{
            System.out.println(3);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    static boolean check(long n){
        for(int i = 2;i<=Math.sqrt(n);i++){
            if(n%i==0) return false;
        }
        return true;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        if(n==2||check(n)){
             System.out.println(1); return;
        }
        else if(n%2==0) System.out.println(2);
        else if(check(n-2)) System.out.println(2);
        else System.out.println(3);
    }

}

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

import javax.print.DocFlavor.INPUT_STREAM;

public class name
{

	static int pd(long n)
	{
		long i;
		/*
		 * if(n==1) return 1;
		 */
		for (i = 2; i * i <= n; i++)
		{
			if (n % i == 0)
				break;
		}
		if (i * i > n)
			return 1;
		return 0;
	}

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		String s;
		Scanner sc = new Scanner(System.in);
		long n=0;
	//	while (sc.hasNext())
		{
			n=sc.nextLong();
			int count = 0;
			if (pd(n) == 1)
			{
				System.out.println(1);
			}
			else if(n%2==0||pd(n-2)==1||pd(n-3)==1||pd(n-5)==1)
			{
				System.out.println(2);
			}
			else
			{
				System.out.println(3);
			}
			//System.out.println(count);
		}
		// System.out.println(count);
	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kraken
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskD solver = new TaskD();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskD {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      long n = in.nextLong();
      if (prime(n)) {
        out.println(1);
      } else if (n % 2 == 0) {
        out.println(2);
      } else if (prime(n - 2)) {
        out.println(2);
      } else {
        out.println(3);
      }
    }

    private boolean prime(long n) {
      if (n <= 1)
        return false;
      if (n <= 3)
        return true;
      if (n % 2 == 0 || n % 3 == 0)
        return false;
      for (int i = 5; i * i <= n; i++)
        if (n % i == 0)
          return false;
      return true;
    }

  }
}

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

import javax.print.DocFlavor.INPUT_STREAM;

public class name
{

	static int pd(long n)
	{
		long i;
		/*
		 * if(n==1) return 1;
		 */
		for (i = 2; i * i <= n; i++)
		{
			if (n % i == 0)
				break;
		}
		if (i * i > n)
			return 1;
		return 0;
	}

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		String s;
		Scanner sc = new Scanner(System.in);
		long n=0;
		while (sc.hasNext())
		{
			n=sc.nextLong();
			int count = 0;
			if (pd(n) == 1)
			{
				System.out.println(1);
			}
			else if(n%2==0||pd(n-2)==1||pd(n-3)==1||pd(n-5)==1)
			{
				System.out.println(2);
			}
			else
			{
				System.out.println(3);
			}
			//System.out.println(count);
		}
		// System.out.println(count);
	}

}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Taxes {
    InputStream is;
    PrintWriter pw;
    String INPUT = "";
    long L_INF = (1L << 60L);

    void solve() {
        int n = ni(), m, x = n;

        if (n < 4) {
            pw.println(1);
            return;
        }
        if(n%2==1 && checkPrime(n)) {
            pw.println(1);
        }
        else if(n%2==1 && checkPrime(n-2)){
            pw.println(2);
        }
        else if(n%2==1)
            pw.println(3);
        else
            pw.println(2);

    }

    boolean checkPrime(long n){
        for (long i = 2; i*i <=n ; i++) {
            if(n%i==0){
//                pw.println(n % 2 == 1 ? 3 : 2);
                return false;
            }
        }
        return true;
    }

    void run() throws Exception {
//		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
        is = System.in;
        pw = new PrintWriter(System.out);

        long s = System.currentTimeMillis();
//        int t = ni();
//        while (t-- > 0)
        solve();
        pw.flush();
        tr(System.currentTimeMillis() - s + "ms");
    }

    public static void main(String[] args) throws Exception {
        new Taxes().run();
    }

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte() {
        if (lenbuf == -1) throw new InputMismatchException();
        if (ptrbuf >= lenbuf) {
            ptrbuf = 0;
            try {
                lenbuf = is.read(inbuf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (lenbuf <= 0) return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) {
        return !(c >= 33 && c <= 126);
    }

    private int skip() {
        int b;
        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
        return b;
    }

    private double nd() {
        return Double.parseDouble(ns());
    }

    private char nc() {
        return (char) skip();
    }

    private String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n) {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while (p < n && !(isSpaceChar(b))) {
            buf[p++] = (char) b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m) {
        char[][] map = new char[n][];
        for (int i = 0; i < n; i++) map[i] = ns(m);
        return map;
    }

    private int[] na(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = ni();
        return a;
    }

    private int ni() {
        int num = 0, b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl() {
        long num = 0;
        int b;
        boolean minus = false;
        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
        if (b == '-') {
            minus = true;
            b = readByte();
        }

        while (true) {
            if (b >= '0' && b <= '9') {
                num = num * 10 + (b - '0');
            } else {
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

    private void tr(Object... o) {
        if (!oj) System.out.println(Arrays.deepToString(o));
    }
}

import java.util.Scanner;
import java.math.*;

public class Main
{
	public static void main(String[] args)
	{
		int N;
		Scanner in = new Scanner(System.in);

		N = in.nextInt();

		if (BigInteger.valueOf(N).isProbablePrime(100))
            System.out.println("1");
        else
        {
            if (N % 2 == 0)
                System.out.println("2");
            else
            {
                if (BigInteger.valueOf(N-2).isProbablePrime(100))
                    System.out.println("2");
                else
                    System.out.println("3");
            }
        }
	}
}

import java.io.*;
import java.util.*;
import java.awt.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        StringBuilder sb=new StringBuilder();
        int n=sc.nextInt();
        if(n%2==0){
            if(n==2) System.out.println(1);
            else System.out.println(2);
        }
        else{
            if(isPrime(n)) System.out.println(1);
            else if(isPrime(n-2)) System.out.println(2);
            else System.out.println(3);
        }
    }
    static boolean isPrime(int n){
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0 || n%(n/i)==0)return false;
        }
        return true;
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }
    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt() { return Integer.parseInt(next()); }
    long nextLong() { return Long.parseLong(next()); }
    double nextDouble() { return Double.parseDouble(next()); }
    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}

import java.io.*;
import java.util.*;

public class Main {
    static Scanner scan;
    static PrintStream out;

    public static void main (String[] args) throws IOException {
        scan = new Scanner(System.in);
        out = new PrintStream(System.out);
        int n = scan.nextInt();
        boolean prime = isPrime(n);

        if (n >= 4) {
        	if (isPrime(n - 2) && (!prime)) {
        		out.print(2);
        		return;
        	}
        	if (n % 2 == 0) {
        		out.print(2);
        	} else {
        		if (prime) {out.print(1);}
        		else {out.print(3);}
        	}
        } else {
        	out.print(1);
        }

    }

    public static boolean isPrime (int a) {
    	for (int i = 2; i * i <= a; i++) {
    		if (a % i == 0) {return false;}
    	}
    	return true;
    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by matt on 11/27/16.
 */
public class Main {
    //  static char[] primes;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
     //   System.out.println(isPrime(4));
        long n = sc.nextLong();
        if (isPrime(n)) {
            System.out.println(1);
        } else if (n % 2 == 0) {
            System.out.println(2);
        } else if (isPrime(n - 2)) {
            System.out.println(2);
        } else {
            System.out.println(3);
        }

    }

    public static boolean isPrime(long n) {
        //check if n is a multiple of 2
        if (n == 2) return true;
        if (n % 2 == 0) return false;
        //if not, then just check the odds
        for (long i = 3; i * i <= n; i += 2) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

}

/*
int n;
vector<char> prime (n+1, true);
prime[0] = prime[1] = false;
for (int i=2; i<=n; ++i)
	if (prime[i])
		if (i * 1ll * i <= n)
			for (int j=i*i; j<=n; j+=i)
				prime[j] = false;
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;
public class Q1 {
	public static void main(String[] args)
	{
		mYScanner in = new mYScanner();
		int n = in.nextInt();
		if(n!=2 && n%2==0)
			System.out.println(2);
		else
		{
			if(BigInteger.valueOf(n).isProbablePrime(1))
				System.out.println(1);
			else if(BigInteger.valueOf(n-2).isProbablePrime(1))
				System.out.println(2);
			else
				System.out.println(3);
		}
	}
}
class mYScanner
{
	BufferedReader br ;
	StringTokenizer st;

	public mYScanner()
	{
		br = new BufferedReader(new InputStreamReader(System.in));
		st = null;
	}
	 public String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }
	public int nextInt()
	{
		return Integer.parseInt(next());
	}}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author adzo261
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DTaxes solver = new DTaxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class DTaxes {
        private boolean isPrime(int n) {
            for (int i = 2; i * i <= n; i++) {
                if (n % i == 0) {
                    return false;
                }
            }
            return true;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();

            if (isPrime(n)) {
                out.println(1);
            } else if (n % 2 != 0) {
                if (isPrime(n - 2)) {
                    out.println(2);
                } else {
                    out.println(3);
                }
            } else {
                out.println(2);
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class D382 {
	static ArrayList<Integer> list;
	static int[] memo;
	static int[] val;
	public static void main(String[] args) {
		MyScanner scan = new MyScanner();
		int N = scan.nextInt();

		if(N==2||N==3||N==5||N==7){
			System.out.println(1);
		}
		else if(N%2==0){
			System.out.println(2);
		}
		else{
			if(BigInteger.valueOf(N).isProbablePrime(30))System.out.println(1);
			else if (BigInteger.valueOf(N-2).isProbablePrime(30))System.out.println(2);
			else System.out.println(3);
		}
	}
	private static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {br = new BufferedReader(new InputStreamReader(System.in));}
		String next(){
			while(st==null||!st.hasMoreElements()){
				try{st = new StringTokenizer(br.readLine());}
				catch(IOException e){e.printStackTrace();}
			}return st.nextToken();
		}
		public String nextLine() {
			StringBuilder s = new StringBuilder();
			if(st!=null&&st.hasMoreTokens()){
				while(st.hasMoreTokens())s.append(st.nextToken()+" ");
				return s.toString();
			}else{
				try{s=new StringBuilder(br.readLine());}
				catch(Exception e) {}
			}
			return s.toString().trim();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong(){return Long.parseLong(next());}
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class test {
	static boolean prime[];

	static ArrayList<Integer> primes;

	public static void main(String[] args) {
//		int test = fs.nextInt();
		int test = 1;
		// int t = fs.nextInt();

		for (int cases = 0; cases < test; cases++) {
			int n = fs.nextInt();
			if (isPrime(n)) {
				op.print(1);
			} else if (n % 2 == 0) {
				op.print(2);
			} else {
				if (isPrime(n - 2)) {
					op.print(2);
				} else {
					op.print(3);
				}
			}

			op.flush();
		}

	}

	static void sieveOfEratosthenes(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.
		primes = new ArrayList<Integer>();
		prime = new boolean[n + 1];
		for (int i = 0; i < n; i++)
			prime[i] = true;
		for (int p = 2; p * p <= n; p++) {
			if (prime[p] == true) {
				for (int i = p * p; i <= n; i += p)
					prime[i] = false;
			}
		}
		for (int i = 2; i < prime.length; i++) {
			if (prime[i])
				primes.add(i);
		}

	}

	static long expmodulo(long a, long b, long c) {
		long x = 1;
		long y = a;
		while (b > 0) {
			if (b % 2 == 1) {
				x = (x * y) % c;
			}
			y = (y * y) % c; // squaring the base
			b /= 2;
		}
		return (long) x % c;
	}

	static int modInverse(int a, int m) {
		int m0 = m;
		int y = 0, x = 1;

		if (m == 1)
			return 0;

		while (a > 1) {
			// q is quotient
			int q = a / m;

			int t = m;

			// m is remainder now, process
			// same as Euclid's algo
			m = a % m;
			a = t;
			t = y;

			// Update x and y
			y = x - q * y;
			x = t;
		}

		// Make x positive
		if (x < 0)
			x += m0;

		return x;
	}

	static int countBits(int number) {
		return (int) (Math.log(number) / Math.log(2) + 1);
	}

	static int countDifferentBits(int a, int b) {
		int count = 0;
		for (int i = 0; i < 32; i++) {
			if (((a >> i) & 1) != ((b >> i) & 1)) {
				++count;
			}
		}
		return count;
	}

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

	static void sortMyMapusingValues(HashMap<String, Integer> hm) {

		List<Map.Entry<String, Integer>> capitalList = new LinkedList<>(hm.entrySet());

		Collections.sort(capitalList, new Comparator<Map.Entry<String, Integer>>() {
			public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
				return (o1.getValue()).compareTo(o2.getValue());
			}
		});
		HashMap<String, Integer> result = new HashMap<>();
		for (Map.Entry<String, Integer> entry : capitalList) {
			result.put(entry.getKey(), entry.getValue());
		}
	}

	static boolean ispowerof2(long num) {
		if ((num & (num - 1)) == 0)
			return true;
		return false;
	}

	static void primeFactors(int n) {
		while (n % 2 == 0) {
			System.out.print(2 + " ");
			n /= 2;
		}
		for (int i = 3; i <= Math.sqrt(n); i += 2) {
			while (n % i == 0) {
				System.out.print(i + " ");
				n /= i;
			}
		}
		if (n > 2)
			System.out.print(n);
	}

	static boolean isPrime(long n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		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;
	}

	static class Graph {
		HashMap<Integer, LinkedList<Integer>> hm = new HashMap<Integer, LinkedList<Integer>>();

		private void addVertex(int vertex) {
			hm.put(vertex, new LinkedList<>());
		}

		private void addEdge(int source, int dest, boolean bi) {
			if (!hm.containsKey(source))
				addVertex(source);
			if (!hm.containsKey(dest))
				addVertex(dest);
			hm.get(source).add(dest);
			if (bi) {
				hm.get(dest).add(source);
			}
		}

		private boolean uniCycle(int i, HashSet<Integer> visited, int parent) {
			visited.add(i);
			LinkedList<Integer> list = hm.get(i);
			Iterator<Integer> it = list.iterator();
			while (it.hasNext()) {
				Integer integer = (Integer) it.next();
				if (!visited.contains(integer)) {
					if (uniCycle(integer, visited, i))
						return true;
				} else if (integer != parent) {
					return true;
				}
			}
			return false;
		}

		private boolean uniCyclic() {
			HashSet<Integer> visited = new HashSet<Integer>();
			Set<Integer> set = hm.keySet();
			for (Integer integer : set) {
				if (!visited.contains(integer)) {
					if (uniCycle(integer, visited, -1)) {
						return true;
					}
				}
			}
			return false;
		}

		private boolean isbiCycle(int i, HashSet<Integer> visited, HashSet<Integer> countered) {
			if (countered.contains(i))
				return true;
			if (visited.contains(i))
				return false;
			visited.add(i);
			countered.add(i);
			LinkedList<Integer> list = hm.get(i);
			Iterator<Integer> it = list.iterator();
			while (it.hasNext()) {
				Integer integer = (Integer) it.next();
				if (isbiCycle(integer, visited, countered)) {
					return true;
				}
			}
			countered.remove(i);
			return false;
		}

		private boolean isbiCyclic() {
			HashSet<Integer> visited = new HashSet<Integer>();
			HashSet<Integer> countered = new HashSet<Integer>();
			Set<Integer> set = hm.keySet();
			for (Integer integer : set) {
				if (isbiCycle(integer, visited, countered)) {
					return true;
				}
			}
			return false;
		}
	}

	static class Node {
		Node left, right;
		int data;

		public Node(int data) {
			this.data = data;
		}

		public void insert(int val) {
			if (val <= data) {
				if (left == null) {
					left = new Node(val);
				} else {
					left.insert(val);
				}
			} else {
				if (right == null) {
					right = new Node(val);
				} else {
					right.insert(val);
				}
			}
		}

		public boolean contains(int val) {
			if (data == val) {
				return true;
			} else if (val < data) {
				if (left == null) {
					return false;
				} else {
					return left.contains(val);
				}
			} else {
				if (right == null) {
					return false;
				} else {
					return right.contains(val);
				}
			}
		}

		public void inorder() {
			if (left != null) {
				left.inorder();
			}
			System.out.print(data + " ");
			if (right != null) {
				right.inorder();
			}
		}

		public int maxDepth() {
			if (left == null)
				return 0;
			if (right == null)
				return 0;
			else {
				int ll = left.maxDepth();
				int rr = right.maxDepth();
				if (ll > rr)
					return (ll + 1);
				else
					return (rr + 1);
			}
		}

		public int countNodes() {
			if (left == null)
				return 1;
			if (right == null)
				return 1;
			else {
				return left.countNodes() + right.countNodes() + 1;
			}
		}

		public void preorder() {
			System.out.print(data + " ");
			if (left != null) {
				left.inorder();
			}

			if (right != null) {
				right.inorder();
			}

		}

		public void postorder() {
			if (left != null) {
				left.inorder();
			}

			if (right != null) {
				right.inorder();
			}
			System.out.print(data + " ");

		}

		public void levelorder(Node node) {
			LinkedList<Node> ll = new LinkedList<Node>();
			ll.add(node);
			getorder(ll);

		}

		public void getorder(LinkedList<Node> ll) {
			while (!ll.isEmpty()) {
				Node node = ll.poll();
				System.out.print(node.data + " ");
				if (node.left != null)
					ll.add(node.left);
				if (node.right != null)
					ll.add(node.right);
			}
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static class Pair {
		int first, second;

		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}

	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void printLine(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}

		public void flush() {
			writer.flush();
		}

	}

	private static final Scanner sc = new Scanner(System.in);
	private static final FastReader fs = new FastReader();
	private static final OutputWriter op = new OutputWriter(System.out);

	static int[] getintarray(int n) {
		int ar[] = new int[n];
		for (int i = 0; i < n; i++) {
			ar[i] = fs.nextInt();
		}
		return ar;
	}

	static long[] getlongarray(int n) {
		long ar[] = new long[n];
		for (int i = 0; i < n; i++) {
			ar[i] = fs.nextLong();
		}
		return ar;
	}

	static int[][] get2darray(int n, int m) {
		int ar[][] = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ar[i][j] = fs.nextInt();
			}
		}
		return ar;
	}

	static Pair[] getpairarray(int n) {
		Pair ar[] = new Pair[n];
		for (int i = 0; i < n; i++) {
			ar[i] = new Pair(fs.nextInt(), fs.nextInt());
		}
		return ar;
	}

	static void printarray(int ar[]) {
		for (int i : ar) {
			op.print(i + " ");
		}
		op.flush();
	}

	static int fact(int n) {
		int fact = 1;
		for (int i = 2; i <= n; i++) {
			fact *= i;
		}
		return fact;
	}

//

	// function to find largest prime factor

}

import java.util.Scanner;

public class taxes {
	static boolean isPr(int n) {
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0)
				return false;
		}
		return true;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (isPr(n)) {
			System.out.println(1);
		} else if (n % 2 == 0) {
			System.out.println(2);
		} else {
			if (isPr(n - 2))
				System.out.println(2);
			else
				System.out.println(3);
		}
		sc.close();
	}
}

import java.util.*;

public class D735 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int result;
        if (isPrime(n)) {
            result = 1;
        } else if (n % 2 == 0 || isPrime(n - 2)) {
            result = 2;
        } else {
            result = 3;
        }
        System.out.println(result);
    }

    private static boolean isPrime(int n) {
        int d = 2;

        while (d * d < n && n % d != 0) {
            d++;
        }

        return d * d > n;
    }
}

import java.io.*;
import java.util.*;
import java.math.*;
public class div382D
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	public static void main(String[] args) throws IOException {
		new div382D().run();
	}
	void run() throws IOException {
		//in=new BufferedReader(new FileReader("input.txt"));
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	void solve() throws IOException {
		int n=ni();
		ob.println(rec(n));
	}
	int rec(int n) {
		BigInteger x=new BigInteger(""+n);
		if(x.isProbablePrime(1000))
			return 1;
		else if(n%2==0)
			return 2;
		else {
			for(int j=n-2 ; ; --j) {
				BigInteger p=new BigInteger(""+j);
				if(p.isProbablePrime(1000)) {
					return 1+rec(n-j);
				}
			}
		}
	}
	String ns() throws IOException {
		return nextToken();
	}
	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int[] nia(int start,int b) throws IOException {
		int a[]=new int[b];
		for(int i=start;i<b;i++)
			a[i]=ni();
		return a;
	}
	long[] nla(int start,int n) throws IOException {
		long a[]=new long[n];
		for (int i=start; i<n ;i++ ) {
			a[i]=nl();
		}
		return a;
	}
}

import java.util.Scanner;

public class Russia {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int sum = 0;
        int i = n;
        if(j(n) && n != 4){
            System.out.print("1");
            return;
        }
        if(j(n - 2)){
            System.out.print("2");
            return;
        }
        if(n % 2 != 0){
            System.out.print("3");
        }
        else{
            System.out.print("2");
        }
    }
    public static boolean j(int i){
        if(i == 2){
            return true;
        }
        for (int j = 2; j < Math.sqrt(i) + 1; j++) {
            if(i % j == 0){
                return false;
            }
        }
        return true;

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Taxes
{
	static ArrayList<Integer> list=new ArrayList<Integer>();
	public static void main(String[] args)
	 {
		FffScanner scan=new FffScanner(System.in);
		int n=scan.nextInt();
		if(n<=1)
		{
			System.out.println(0);
		}
		else if(isPrime(n))
		{
			System.out.println(1);
		}
		else if(n%2==0||isPrime(n-2))
		{
			System.out.println(2);
		}
		else
		{
			System.out.println(3);
		}
	 }
/*	static int isPowOf2(int n)
	{
		if( n!=0&&((n&(n-1))==0))
		{
			int count=0;
			while((n&1)!=1)
			{
				count++;
				n=n>>1;
			}
			return count;
		}
		return -1;
	}
	*/
/*	static int primeFactorization(int num)
	{
		int count=0;
		int temp1=num;
		int numRef=num;
		for(int offset=2;offset<=Math.sqrt(num);offset++)
		 {
			if(num%offset==0&&isPrime(offset))
			{
				//System.out.println("-"+offset);
				while(num%offset==0)
				{
					num/=offset;
					count++;
				}

			}
			if(isPrime(num))
			{
				num=1;
				count++;
			}
			if((num/offset)>0&&(num/offset)<temp1&&num%(num/offset)==0&&isPrime(num/offset))
			{
				//System.out.println("="+num/offset);
				int temp=num/offset;
				while(num%temp==0)
				{
					num/=offset;
					count++;
				}

			}
			if(isPrime(num))
			{
				//System.out.println(num);
				num=1;
				count++;
			}

		 }
		if(count==0)return 1;
		return count;

	}
	*/
	static boolean isPrime(int num)
	{
		if(num<2)
		  {
			return false;
		  }
		if(num==2)
		  {
			return true;
	 	  }
		if(num%2==0)
		{
			return false;
		}
		else
		{
			for(int i=3;i<=(int)sqrt(num);i+=2)
			{
				if(num%i==0)
				{
					return false;
				}
			}
		}
		return true;
	}
	static double  sqrt(double num)
	{
		double temp=num/2;
		double sr=temp;
		do
		{
			temp=sr;
			sr=(temp+(num/temp))/2;
		}while(sr-temp!=0);
		return sr;
	}
}
class FffScanner
{
	StringTokenizer st;
	BufferedReader br;
	public FffScanner(InputStream is)
	 {
		br=new BufferedReader(new InputStreamReader(is));
	 }
	public String next()
	 {
		while(st==null||!st.hasMoreElements())
		{
			String s=null;
			try
			{
				s=br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}
			if(s==null)
			{
				return null;
			}
			st=new StringTokenizer(s);
		}
		return st.nextToken();
	  }
	public int nextInt()
	  {
		return Integer.parseInt(next());
	  }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sin = new Scanner(System.in);
		int n = sin.nextInt();

		if(isP(n))
			System.out.println(1);
		else if(n%2==0)
			System.out.println(2);
		else if(isP(n-2))
			System.out.println(2);
		else
			System.out.println(3);
	}

	static boolean isP(int n){
		if(n<=1) return false;
		if(n==2) return true;
		if(n%2==0) return false;

		for(long i = 3; i*i <= n; i += 2){
			if(n%i==0) return false;
		}

		return true;
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class Main {
	static StreamTokenizer sc=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException {
		sc.nextToken();
		return (int)sc.nval;
	}
	static long nextLong() throws IOException {
		sc.nextToken();
		return (long)sc.nval;
	}
	static String next() throws IOException{
		sc.nextToken();
		return sc.sval;
	}
	static int maxn=200000;
	static boolean notPrime[]=new boolean[maxn];
	static boolean isPrime(int x) {
		notPrime[1]=true;
		for(int i=2;(long)i*i<=x;i++) {
			if(!notPrime[i]) {
				if(x%i==0) {
					return false;
				}
				for(int j=i*2;(long)j*j<=x;j+=i) {
					notPrime[j]=true;
				}
			}
		}
		return true;
	}
	public static void main(String args[]) throws IOException {
		//System.out.println(Integer.parseInt("-5"));
		PrintWriter out=new PrintWriter(System.out);
		//InputReader sc=new InputReader(System.in);
		int n=nextInt();
		if(n<4) {
			out.print(1);
		}else if(n%2==0) {
			out.print(2);
		}else {
			if(isPrime(n)) {
				out.print(1);
			}else {
				boolean flag=false;
				for(int i=2;(long)i*i<=(n-2);i++)
					if(!notPrime[i]) {
						//System.out.println(i);
						if((n-2)%i==0) {
							flag=true;//不是素数
							break;
						}
					}
				if(flag) {
					out.print(3);
				}else {
					out.print(2);
				}
			}
		}
		out.flush();
		out.close();
	}
}
/*class InputReader {

	private final InputStream stream;
	private final byte[] buf = new byte[8192];
	private int curChar, snumChars;

	public InputReader(InputStream st) {
		this.stream = st;
	}

	public int read() {
		if (snumChars == -1)
			throw new InputMismatchException();
		if (curChar >= snumChars) {
			curChar = 0;
			try {
				snumChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (snumChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int nextInt() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public long nextLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public int[] nextIntArray(int n) {
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}
}*/

import java.util.Scanner;

public class C03 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		if (n % 2 == 0) {
			if (n == 2)
				System.out.println(1);
			if (n != 2)
				System.out.println(2);
		}
		if (n % 2 == 1) {
			boolean x = true, y = true;
			int l = sqrt(n);
			for (int i = 2; i <= l; i++) {
				if (n % i == 0) {
					x = false;
					break;
				}
			}
			if (x)
				System.out.println(1);
			if (!x) {
				for (int i = 2; i <= l; i++) {
					if ((n - 2) % i == 0) {
						y = false;
						break;
					}
				}
				if (y)
					System.out.println(2);

			}
			if (!x && !y)
				System.out.println(3);
		}
	}

	public static int sqrt(int n) {
		for (int i = 1; i < n; i++) {
			if (i * i > n) {
				return i;
			}
		}
		return 1;
	}

}

import java.io.*;
import java.util.*;

public class Main {
    static FastScanner in;
    static int n;
    static long ans = 0;

    public static void main(String[] args) throws IOException {
        //      Scanner in = new Scanner(new File("input.txt"));
        //        Scanner in = new Scanner(System.in);
        //        in = new FastScanner("input.txt");
        in = new FastScanner(System.in);
        n = in.nextInt();
        if (isPrime(n))
            System.out.println(1);
        else if (n % 2 == 0)
            System.out.println(2);
        else {
            if (isPrime(n - 2))
                System.out.println(2);
            else
                System.out.println(3);
        }
    }

    static boolean isPrime(int n) {
        if (n == 2)
            return true;
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

}

class FastScanner {

    BufferedReader br;
    StringTokenizer tokenizer;

    FastScanner(String fileName) throws FileNotFoundException {
        this(new FileInputStream(new File(fileName)));
    }

    FastScanner(InputStream is) {
        br = new BufferedReader(new InputStreamReader(is));
    }

    String nextLine() throws IOException {
        tokenizer = null;
        return br.readLine();
    }

    String next() throws IOException {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    char nextChar() throws IOException {
        return next().charAt(0);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.stream.Stream;

public class Solution implements Runnable {

	static final double time = 1e9;
	static final int MOD = (int) 1e9 + 7;
	static final long mh = Long.MAX_VALUE;
	static final Reader in = new Reader();
	static final PrintWriter out = new PrintWriter(System.out);
	StringBuilder answer = new StringBuilder();

	public static void main(String[] args) {
		new Thread(null, new Solution(), "persefone", 1 << 28).start();
	}

	@Override
	public void run() {
		long start = System.nanoTime();
		solve();
		printf();
		long elapsed = System.nanoTime() - start;
//		out.println("stamp : " + elapsed / time);
//		out.println("stamp : " + TimeUnit.SECONDS.convert(elapsed, TimeUnit.NANOSECONDS));
		close();
	}

	void solve() {

		int n = in.nextInt();
		if (isPrime(n)) {
			printf(1);
			return;
		}
		if (isPrime(n - 2)) {
			printf(2);
			return;
		}
		printf(n % 2 == 0 ? 2 : 3);
	}

	int pow(int a, int b, int p){
		long ans = 1, base = a;
		while (b > 0){
			if ((b & 1) > 0) {
				ans *= base %= p;
			}
			base *= base %= p;
			b >>= 1;
		}
		return (int)ans;
	}

	public static int[] enumLowestPrimeFactors(int n) {
		int tot = 0;
		int[] lpf = new int[n + 1];
		int u = n + 32;
		double lu = Math.log(u);
		int[] primes = new int[(int) (u / lu + u / lu / lu * 1.5)];
		for (int i = 2; i <= n; i++)
			lpf[i] = i;
		for (int p = 2; p <= n; p++) {
			if (lpf[p] == p)
				primes[tot++] = p;
			int tmp;
			for (int i = 0; i < tot && primes[i] <= lpf[p] && (tmp = primes[i] * p) <= n; i++) {
				lpf[tmp] = primes[i];
			}
		}
		return lpf;
	}

	public static int[] enumNumDivisorsFast(int n, int[] lpf)
	{
		int[] nd = new int[n+1];
		nd[1] = 1;
		for(int i = 2;i <= n;i++){
			int j = i, e = 0;
			while(j % lpf[i] == 0){
				j /= lpf[i];
				e++;
			}
			nd[i] = nd[j] * (e+1);
		}
		return nd;
	}

	boolean isPrime(long n) {

		for (int i = 2; 1l * i * i <= n; i++)
			if (n % i == 0)
				return false;
		return true;
	}

	void printf() {
		out.print(answer);
	}

	void close() {
		out.close();
	}

	void printf(Stream<?> str) {
		str.forEach(o -> add(o, " "));
		add("\n");
	}

	void printf(Object... obj) {
		printf(false, obj);
	}

	void printfWithDescription(Object... obj) {
		printf(true, obj);
	}

	private void printf(boolean b, Object... obj) {

		if (obj.length > 1) {
			for (int i = 0; i < obj.length; i++) {
				if (b) add(obj[i].getClass().getSimpleName(), " - ");
				if (obj[i] instanceof Collection<?>) {
					printf((Collection<?>) obj[i]);
				} else if (obj[i] instanceof int[][]) {
					printf((int[][])obj[i]);
				} else if (obj[i] instanceof long[][]) {
					printf((long[][])obj[i]);
				} else if (obj[i] instanceof double[][]) {
					printf((double[][])obj[i]);
				} else printf(obj[i]);
			}
			return;
		}

		if (b) add(obj[0].getClass().getSimpleName(), " - ");
		printf(obj[0]);
	}

	void printf(Object o) {
		if (o instanceof int[])
			printf(Arrays.stream((int[]) o).boxed());
		else if (o instanceof char[])
			printf(new String((char[]) o));
		else if (o instanceof long[])
			printf(Arrays.stream((long[]) o).boxed());
		else if (o instanceof double[])
			printf(Arrays.stream((double[]) o).boxed());
		else if (o instanceof boolean[]) {
			for (boolean b : (boolean[]) o) add(b, " ");
			add("\n");
		}
		else
			add(o, "\n");
	}

	void printf(int[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(long[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(double[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(boolean[]... obj) {
		for (int i = 0; i < obj.length; i++) printf(obj[i]);
	}

	void printf(Collection<?> col) {
		printf(col.stream());
	}

	<T, K> void add(T t, K k) {
		if (t instanceof Collection<?>) {
			((Collection<?>) t).forEach(i -> add(i, " "));
		} else if (t instanceof Object[]) {
			Arrays.stream((Object[]) t).forEach(i -> add(i, " "));
		} else
			add(t);
		add(k);
	}

	<T> void add(T t) {
		answer.append(t);
	}

	@SuppressWarnings("unchecked")
	<T extends Comparable<? super T>> T min(T... t) {
		if (t.length == 0)
			return null;
		T m = t[0];
		for (int i = 1; i < t.length; i++)
			if (t[i].compareTo(m) < 0)
				m = t[i];
		return m;
	}

	@SuppressWarnings("unchecked")
	<T extends Comparable<? super T>> T max(T... t) {
		if (t.length == 0)
			return null;
		T m = t[0];
		for (int i = 1; i < t.length; i++)
			if (t[i].compareTo(m) > 0)
				m = t[i];
		return m;
	}

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

	long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	// c = gcd(a, b) -> extends gcd method: ax + by = c <----> (b % a)p + q = c;
	int[] ext_gcd(int a, int b) {
		if (b == 0) return new int[] {a, 1, 0 };
		int[] vals = ext_gcd(b, a % b);
		int d = vals[0]; // gcd
	    int p = vals[2]; //
		int q = vals[1] - (a / b) * vals[2];
		return new int[] { d, p, q };
	}

	// find any solution of the equation: ax + by = c using extends gcd
	boolean find_any_solution(int a, int b, int c, int[] root) {
		int[] vals = ext_gcd(Math.abs(a), Math.abs(b));
		if (c % vals[0] != 0) return false;
		printf(vals);
		root[0] = c * vals[1] / vals[0];
		root[1] = c * vals[2] / vals[0];
		if (a < 0) root[0] *= -1;
		if (b < 0) root[1] *= -1;
		return true;
	}

	int mod(int x) { return x % MOD; }

	int mod(int x, int y) { return mod(mod(x) + mod(y)); }

	long mod(long x) { return x % MOD; }

	long mod (long x, long y) { return mod(mod(x) + mod(y)); }

	int lw(long[] f, int l, int r, long k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] >= k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int up(long[] f, int l, int r, long k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] > k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int lw(int[] f, int l, int r, int k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] >= k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	int up(int[] f, int l, int r, int k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (f[m] > k) r = m - 1; else l = m + 1;
		}
		return l;
	}

	<K extends Comparable<K>> int lw(List<K> li, int l, int r, K k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (li.get(m).compareTo(k) >= 0)
		    	r = m - 1;
		    else
		    	l = m + 1;
		}
		return l;
	}

	<K extends Comparable<K>> int up(List<K> li, int l, int r, K k) {
		int R = r, m = 0;
		while (l <= r) {
			m = l + r >> 1;
		    if (m == R) return m;
		    if (li.get(m).compareTo(k) > 0)
		    	r = m - 1;
		    else
		    	l = m + 1;
		}
		return l;
	}

	<K extends Comparable<K>> int bs(List<K> li, int l, int r, K k) {
		while (l <= r) {
			int m = l + r >> 1;
		    if (li.get(m) == k) return m;
		    else if (li.get(m).compareTo(k) < 0)
		    	l = m + 1;
		    else
		    	r = m - 1;
		}
		return -1;
	}

	long calc(int base, int exponent) {
		if (exponent == 0) return 1;
		if (exponent == 1) return base % MOD;
		long m = calc(base, exponent / 2);
		if (exponent % 2 == 0) return (m * m) % MOD;
		return (base * ((m * m) % MOD)) % MOD;
	}

	long calc(int base, long exponent) {
		if (exponent == 0) return 1;
		if (exponent == 1) return base % MOD;
		long m = calc(base, exponent / 2);
		if (exponent % 2 == 0) return (m * m) % MOD;
		return (base * ((m * m) % MOD)) % MOD;
	}

	long calc(long base, long exponent) {
		if (exponent == 0) return 1;
		if (exponent == 1) return base % MOD;
		long m = calc(base, exponent / 2);
		if (exponent % 2 == 0) return (m * m) % MOD;
		return (base * (m * m % MOD)) % MOD;
	}

	long power(int base, int exponent) {
		if (exponent == 0) return 1;
		long m = power(base, exponent / 2);
		if (exponent % 2 == 0) return m * m;
		return base * m * m;
	}

	void swap(int[] a, int i, int j) {
		a[i] ^= a[j];
		a[j] ^= a[i];
		a[i] ^= a[j];
	}

	void swap(long[] a, int i, int j) {
		long tmp = a[i];
		a[i] = a[j];
		a[j] = tmp;
	}

	static class Pair<K extends Comparable<? super K>, V extends Comparable<? super V>>
			implements Comparable<Pair<K, V>> {
		private K k;
		private V v;

		Pair() {}

		Pair(K k, V v) {
			this.k = k;
			this.v = v;
		}

		K getK() { return k; }

		V getV() { return v; }

		void setK(K k) { this.k = k; }

		void setV(V v) { this.v = v; }

		void setKV(K k, V v) {
			this.k = k;
			this.v = v;
		}

		@SuppressWarnings("unchecked")
		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || !(o instanceof Pair)) return false;
			Pair<K, V> p = (Pair<K, V>) o;
			return k.compareTo(p.k) == 0 && v.compareTo(p.v) == 0;
		}

		@Override
		public int hashCode() {
			int hash = 31;
			hash = hash * 89 + k.hashCode();
			hash = hash * 89 + v.hashCode();
			return hash;
		}

		@Override
		public int compareTo(Pair<K, V> pair) {
			return k.compareTo(pair.k) == 0 ? v.compareTo(pair.v) : k.compareTo(pair.k);
		}

		@Override
		public Pair<K, V> clone() {
			return new Pair<K, V>(this.k, this.v);
		}

		@Override
		public String toString() {
			return String.valueOf(k).concat(" ").concat(String.valueOf(v)).concat("\n");
		}
	}

	static class Reader {
		private BufferedReader br;
		private StringTokenizer st;

		Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			try {
				while (st == null || !st.hasMoreTokens()) {
					st = new StringTokenizer(br.readLine());
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++)
				arr[i] = nextInt();
			return arr;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String s = "";
			try {
				s = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return s;
		}
	}
}

//package com.turtle.bone;

import java.util.Scanner;

public class AK740 {

	public static Scanner cin = new Scanner(System.in);
	public static boolean isPrime(int x){
		int n=x;
		if(x>=2){
			for(int i=2;i*i<=n;i++){
				if(x%i==0){
					return false;
				}
			}
			return true;
		}else{
			return false;
		}

	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		while(cin.hasNext()){
			int n=cin.nextInt();
			int count=0;
			if(isPrime(n)){
				count=1;
			}else if(isPrime(n-2)||n%2==0){
				count=2;
			}else{
				count=3;
			}
			System.out.println(count);

		}
	}

}

import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;

public class D {

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long ans = 0;
		long cur = n;
		if (cur%2 == 0 && cur!=2) System.out.println(2);
		else {
			BigInteger temp = BigInteger.valueOf(cur);
			if (temp.isProbablePrime(1000)) {
				System.out.println(1);
			}
			else {
				temp = BigInteger.valueOf(cur-2);
				if (temp.isProbablePrime(1000)) {
					System.out.println(2);
				}
				else System.out.println(3);
			}

		}

	}

}

import java.io.*;
import java.util.*;

public class Main {

    private void solve(InputReader in, PrintWriter out) {
        long x = in.nextLong();
        if (isPrime(x)) {
            out.println(1);
        } else {
            if (x % 2 == 0) {
                out.println(2);
            } else {
                if (isPrime(x - 2)) {
                    out.println(2);
                } else {
                    out.println(3);
                }
            }
        }
    }

    private boolean isPrime(long n) {
        if (n == 2) {
            return true;
        }

        for (long i = 2; i <= Math.ceil(Math.sqrt(n)); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        new Main().solve(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author wannabe
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        private boolean isPrime(int a) {
            return a < 3 || IntStream.range(2, (int) Math.sqrt(a) + 1).noneMatch(i -> a % i == 0);
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.print(solve(in.nextInt()));
        }

        private int solve(int n) {
            if (isPrime(n)) return 1;
            if (n % 2 == 0 || isPrime(n - 2)) return 2;
            return 3;
        }

    }
}

import java.util.Arrays;
import java.util.Scanner;

public class MainD {
    MyScanner sc    = new MyScanner();
    Scanner   sc2   = new Scanner(System.in);
    long      start = System.currentTimeMillis();
    long      fin   = System.currentTimeMillis();
    final int MOD   = 1000000007;
    int[]     dx    = { 1, 0, 0, -1 };
    int[]     dy    = { 0, 1, -1, 0 };

    void run() {
        int n = sc.nextInt();

        if (isPrime(n)) {
            System.out.println(1);
            return;
        }

        if (n % 2 == 0) {
            System.out.println(2);
        } else {
            System.out.println(isPrime(n - 2) ? 2 : 3);
        }
    }

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

    public static void main(String[] args) {
        new MainD().run();
    }

    void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }

    void debug2(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }

    boolean inner(int h, int w, int limH, int limW) {
        return 0 <= h && h < limH && 0 <= w && w < limW;
    }

    void swap(int[] x, int a, int b) {
        int tmp = x[a];
        x[a] = x[b];
        x[b] = tmp;
    }

    // find minimum i (k <= a[i])
    int lower_bound(int a[], int k) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (k <= a[mid])
                r = mid;
            else
                l = mid;
        }
        // r = l + 1
        return r;
    }

    // find minimum i (k < a[i])
    int upper_bound(int a[], int k) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (k < a[mid])
                r = mid;
            else
                l = mid;
        }
        // r = l + 1
        return r;
    }

    long gcd(long a, long b) {
        return a % b == 0 ? b : gcd(b, a % b);
    }

    long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    boolean palindrome(String s) {
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                return false;
            }
        }
        return true;
    }

    class MyScanner {
        int nextInt() {
            try {
                int c = System.in.read();
                while (c != '-' && (c < '0' || '9' < c))
                    c = System.in.read();
                if (c == '-')
                    return -nextInt();
                int res = 0;
                do {
                    res *= 10;
                    res += c - '0';
                    c = System.in.read();
                } while ('0' <= c && c <= '9');
                return res;
            } catch (Exception e) {
                return -1;
            }
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String next() {
            try {
                StringBuilder res = new StringBuilder("");
                int c = System.in.read();
                while (Character.isWhitespace(c))
                    c = System.in.read();
                do {
                    res.append((char) c);
                } while (!Character.isWhitespace(c = System.in.read()));
                return res.toString();
            } catch (Exception e) {
                return null;
            }
        }

        int[] nextIntArray(int n) {
            int[] in = new int[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextInt();
            }
            return in;
        }

        int[][] nextInt2dArray(int n, int m) {
            int[][] in = new int[n][m];
            for (int i = 0; i < n; i++) {
                in[i] = nextIntArray(m);
            }
            return in;
        }

        double[] nextDoubleArray(int n) {
            double[] in = new double[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextDouble();
            }
            return in;
        }

        long[] nextLongArray(int n) {
            long[] in = new long[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextLong();
            }
            return in;
        }

        char[][] nextCharField(int n, int m) {
            char[][] in = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                for (int j = 0; j < m; j++) {
                    in[i][j] = s.charAt(j);
                }
            }
            return in;
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DTaxes solver = new DTaxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class DTaxes {
        PrintWriter out;
        InputReader in;

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

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            if (!check(n))
                pn(1);
            else if (n % 2 == 0 || !check(n - 2))
                pn(2);
            else
                pn(3);
        }

        int ni() {
            return in.nextInt();
        }

        void pn(Object o) {
            out.println(o);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

import com.sun.org.apache.xalan.internal.xsltc.dom.SortingIterator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Codeforces2 {
    public static void main(String[] args) {

        int tax = 0;
        int n = 0;
        int noChoice = 1;
        int taxModulo = tax;
        List<String> tab = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        tax = sc.nextInt();

        if (tax == 2){
            System.out.println(noChoice);
            return;
        }

        for (int i = 2 ; i < 500 && i < tax; i++) {
            taxModulo = tax % (i);
            if (taxModulo == 0){
                n++;
                System.out.println(i);
                return;
            }
        }
        if (n == 0){
            System.out.println(noChoice);
            return;
        }
        /*String[] newTab = new String[tab.size()];
        newTab = tab.toArray(newTab);
        Integer[] taxValue = new Integer[newTab.length];
        for (int i = 0; i < taxValue.length; i++) {
            taxValue[i] = new Integer(newTab[i]);
        }
        Arrays.sort(taxValue);
        System.out.println(taxValue[0]);*/
    }
}

import java.io.*;
import java.util.*;
import java.math.*;
public class R382D {
	public static void main(String[] args) throws Exception {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long n = Long.parseLong(f.readLine().trim());
		long res=0;
		long number = n;
			for(long i=number;i>=0;i--){
				if(i%2==0 && i != 2) continue;
				if(BigInteger.valueOf(i).isProbablePrime(125) && (number - i >= 2 || number -i==0)) {
					res++;
					number -= i;
//					System.out.println(i);
					if(number==0) break;
					i = number+1;
				}
			}
			System.out.println(res);
	}
}

import java.util.*;
import java.lang.*;

public class Tax {
	public static double inputInteger() {
		Scanner kbd = new Scanner(System.in);
		double num = 0;
		while (!(2 <= num)) {
			num = kbd.nextInt();
		}
		return num;
	}

	public static void checkBurles(double num) {
		int ctr = 0;
		if (num%1 == 0)
			ctr = 1;
		if (num%2 == 0)
			ctr = 2;
		if (num%3 == 0)
			ctr = 3;
		if (num == 3)
			ctr = 1;
		if (num == 2)
			ctr = 1;
		if (num % 5 == 4)
			ctr =3 ;
		switch(ctr) {
			case 1: System.out.println(1); break;
			case 2: System.out.println(2); break;
			case 3: System.out.println(3); break;
			case 5: System.out.println(5); break;
			case 7: System.out.println(7); break;
		}
	}

	public static void main(String [] args) {
		double num = inputInteger();
		checkBurles(num);
	}
}

import java.io.*;
import java.util.*;
public class Taxes {
    public static void main(String[] args) {
        PrintWriter pr = new PrintWriter(System.out);
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        int res=0;
        while(n>1){
            for(long i=n;i>1;i--){
                if(isPrime(i)){
                    res++;
                    n=n-i;
                    break;
                }
            }
        }
        if(n==1)
            res++;
        System.out.println(res);
    }
    public static boolean isPrime(long n){
        for(long i=2;i*i<=n;i++){
            if(n%i==0)
                return false;
        }
        return true;
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long N = in.nextLong();

        if(N >= 4 && N % 2 == 0){
            System.out.println(2);
            return;
        }

        if(new BigInteger(Long.toString(N)).isProbablePrime(10) || N <= 3){
            System.out.println(1);
            return;
        }

        if(N > 1000000009 && new BigInteger(Long.toString(N-1000000009)).isProbablePrime(10) ||
                N > 1000000007 && new BigInteger(Long.toString(N-1000000007)).isProbablePrime(10) || N < 9){
            System.out.println(2);
            return;
        }

        if(N > 9 && N % 2 == 1)
        {
            System.out.println(3);
            return;
        }

    }
}

/**
 * Created by Karan Jobanputra on 31-05-2017.
 */

import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

import static java.lang.Math.*;

public class CF3821B {
    public static boolean isPrime(int n)
    {
        if(n%2 == 0)
        {
            return false;
        }
        for(int i=3;i<=sqrt(n);i+=2)
        {
            if(n%i==0) return false;
        }
        return true;
    }

    public static void main(String args[]) throws Exception {
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        if(n%2==0)
        {
            pw.println("2");
        }
        else
        if(n%2==1)
        {
            if(isPrime(n-2))
            {
                pw.println(2);
            }
            else
            {
                pw.println(3);
            }
        }

        pw.close();
    }

    static class Node implements Comparable<Node> {
        int v;
        int w;

        Node(int v, int w) {
            this.v = v;
            this.w = w;
        }

        public int compareTo(Node node) {
            if (w == node.w)
                return Integer.compare(v, node.v);

            return (-1) * Integer.compare(w, node.w);
        }
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

@SuppressWarnings("unchecked")
public class P735D {

  public void run() throws Exception {
    println(((nextInt() & 1) == 0) ? 2 : 3);
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P735D().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    return ((b > 0) ? gcd(b, a % b) : a);
  }
}

import java.io.*;
import java.util.*;

public class D {
    public static void solution(BufferedReader reader, PrintWriter writer)
            throws IOException {
        In in = new In(reader);
        Out out = new Out(writer);
        int n = in.nextInt();
        if (isPrime(n))
            out.println(1);
        else if (n % 2 == 0)
            out.println(2);
        else
            out.println(3);
    }

    public static boolean isPrime(long n) {
        for (long i = 2; i * i <= n; i++)
            if (n % i == 0)
                return false;
        return true;
    }

    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in));
        PrintWriter writer = new PrintWriter(
                new BufferedWriter(new OutputStreamWriter(System.out)));
        solution(reader, writer);
        writer.close();
    }

    protected static class In {
        private BufferedReader reader;
        private StringTokenizer tokenizer = new StringTokenizer("");

        public In(BufferedReader reader) {
            this.reader = reader;
        }

        public String next() throws IOException {
            while (!tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArray1(int n) throws IOException {
            int[] a = new int[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextInt();
            return a;
        }

        public int[] nextIntArraySorted(int n) throws IOException {
            int[] a = nextIntArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                int t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArray1(int n) throws IOException {
            long[] a = new long[n + 1];
            for (int i = 1; i <= n; i++)
                a[i] = nextLong();
            return a;
        }

        public long[] nextLongArraySorted(int n) throws IOException {
            long[] a = nextLongArray(n);
            Random r = new Random();
            for (int i = 0; i < n; i++) {
                int j = i + r.nextInt(n - i);
                long t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
            Arrays.sort(a);
            return a;
        }
    }

    protected static class Out {
        private PrintWriter writer;
        private static boolean local = System
                .getProperty("ONLINE_JUDGE") == null;

        public Out(PrintWriter writer) {
            this.writer = writer;
        }

        public void print(char c) {
            writer.print(c);
        }

        public void print(int a) {
            writer.print(a);
        }

        public void println(Object a) {
            writer.println(a);
        }

        public void println(Object[] os) {
            for (int i = 0; i < os.length; i++) {
                writer.print(os[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(int[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public void println(long[] a) {
            for (int i = 0; i < a.length; i++) {
                writer.print(a[i]);
                writer.print(' ');
            }
            writer.println();
        }

        public static void db(Object... objects) {
            if (local)
                System.out.println(Arrays.deepToString(objects));
        }
    }
}

import java.io.*;
import java.util.*;

public class Main{

    public static boolean[] primes = new boolean[(int)Math.sqrt(2000000000)];

    public static ArrayList<Integer> primeVals = new ArrayList<>();

    public static void sieve(){
        for(int i = 1; i < primes.length; i++)
            primes[i] = true;
        for(int i = 2; i < primes.length; i++){
            int mult = 2;
            while(mult * i < primes.length) {
                primes[(mult++) * i] = false;

            }
        }
        for(int i = 1; i < primes.length; i++){
            if(primes[i])
                primeVals.add(i);
        }
        Collections.reverse(primeVals);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt();

        sieve();

        int tax = 0;

        for(int prime : primeVals){
            if(N == 0)
                break;
            if(prime <= N)
            {
                tax += N/prime;
                N %= prime;
            }
        }

        System.out.println(tax);

    }
}

import java.util.Scanner;
public class Taxes{
	public static int computeMinPay(int n){
		if(n % 2 == 1 && isPrime(n) == false && n > 20)
			return 3;
		if(isPrime(n) == true)
		    return 1;
		if(isPrime(n-2) == true && n > 100)
		    return 2;
		return 2;
	}
	public static boolean isPrime(int n){
		if(n == 4 || n == 6 || n == 8 || n == 9)
			return false;
		for(int i = n/5; i >= 2; i--){
			if(n % i == 0)
			    return false;
		}
		return true;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(computeMinPay(n));
	}
}

import java.io.*;
import java.util.*;
import java.math.*;
public class div382D
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	public static void main(String[] args) throws IOException {
		new div382D().run();
	}
	void run() throws IOException {
		//in=new BufferedReader(new FileReader("input.txt"));
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	void solve() throws IOException {
		int n=ni();
		ob.println(rec(n));
	}
	int rec(int n) {
		if(n==2)
			return 1;
		else if(n==3)
			return 1;
		else {
			for(int j=n-2 ; ; --j) {
				BigInteger p=new BigInteger(""+j);
				if(p.isProbablePrime(1000)) {
					return 1+rec(n-j);
				}
			}
		}
	}
	String ns() throws IOException {
		return nextToken();
	}
	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int[] nia(int start,int b) throws IOException {
		int a[]=new int[b];
		for(int i=start;i<b;i++)
			a[i]=ni();
		return a;
	}
	long[] nla(int start,int n) throws IOException {
		long a[]=new long[n];
		for (int i=start; i<n ;i++ ) {
			a[i]=nl();
		}
		return a;
	}
}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class CodeForces {

    public static void main(String[] args) {

        Scanner reader;
        Long income;
        double lim;
        Boolean primo=true;

        reader = new Scanner(System.in);

        income = reader.nextLong();

        lim = Math.sqrt(income);

        for (int i = 2; i <= lim; i++) {

            if (income % i == 0) {
                primo = false;
                break;
            }
        }

        if (primo) {
            System.out.println(1);
        } else if(income % 2 == 0) {
            System.out.println(2);
        }
        else{
            System.out.println(3);
        }

    }
}

import java.util.*;
import java.io.*;

public class CF382D
{
	static boolean isPrime(int n)
	{
		if(n==1)
			return false;
		int i,c=0;
		for(i=1;i*i<=n;i++)
		{
			if(n%i==0)
				c++;
		}
		return c==1;
	}
	static int res(int n)
	{
		System.out.println(n);
		if(isPrime(n))
			return 1;
		for(int i=n-2;i>=1;i--)
		{
			if(isPrime(i))
				return 1+res(n-i);
		}
		return 1;
	}
	public static void main(String args[]) {
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		/*------------------------------My Code starts here------------------------------*/
		int n=in.nextInt();
		if(isPrime(n))
			out.println(1);
		else if((n&1)==0)
			out.println(2);
		else
			out.println(3);
		out.close();
		/*------------------------------The End------------------------------------------*/
	}

	public static final long l = (int) (1e9 + 7);

	private static int[] nextIntArray(InputReader in, int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();
		return a;
	}

	private static long[] nextLongArray(InputReader in, int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextLong();
		return a;
	}

	private static int[][] nextIntMatrix(InputReader in, int n, int m) {
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++)
				a[i][j] = in.nextInt();
		}
		return a;
	}

	private static void show(int[] a) {
		for (int i = 0; i < a.length; i++)
			System.out.print(a[i] + " ");
		System.out.println();
	}

	private static void show2DArray(char[][] a) {
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[0].length; j++)
				System.out.print(a[i][j]);
			System.out.println();
		}
	}

	static class Pair {
		private int first;
		private int second;

		public Pair(int i, int j) {
			this.first = i;
			this.second = j;
		}

		public int getFirst() {
			return first;
		}

		public int getSecond() {
			return second;
		}

		public void setFirst(int k) {
			this.first = k;
		}

		public void setSecond(int k) {
			this.second = k;
		}
	}

	static int modPow(int a, int b, int p) {
		int result = 1;
		a %= p;
		while (b > 0) {
			if ((b & 1) != 0)
				result = (result * a) % p;
			b = b >> 1;
			a = (a * a) % p;
		}
		return result;
	}

	public static void SieveOfEratosthenes(int n) {
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, true);
		prime[1] = false;
		int i, j;
		for (i = 2; i * i <= n; i++) {
			if (prime[i]) {
				for (j = i; j <= n; j += i) {
					if (j != i)
						prime[j] = false;
				}
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine() {
			String fullLine = null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Taxes
{

	public static void main(String[] args)
	{

		MyScanner3 sc = new MyScanner3();
		int n = sc.nextInt();

		int p = n;
		int count = 0;

		if(isPrime(n))
		{
			System.out.println(1);
			return;
		}

		while (n > 0)
		{
			p--;
			if(isPrime(p) && (n-p != 1))
			{
//				System.out.println(p);
				n -= p;
				count ++;
				p = n+1;
			}
		}
		System.out.println(count);
	}

	static boolean isPrime(int n) {
	    if(n < 2) return false;
	    if(n == 2 || n == 3) return true;
	    if(n%2 == 0 || n%3 == 0) return false;
	    int sqrtN = (int)Math.sqrt(n)+1;
	    for(int i = 6; i <= sqrtN; i += 6) {
	        if(n%(i-1) == 0 || n%(i+1) == 0) return false;
	    }
	    return true;
	}

	private static int [] generatePrimes(int max) {
	    boolean[] isComposite = new boolean[max + 1];
	    for (int i = 2; i * i <= max; i++) {
	        if (!isComposite [i]) {
	            for (int j = i; i * j <= max; j++) {
	                isComposite [i*j] = true;
	            }
	        }
	    }
	    int numPrimes = 0;
	    for (int i = 2; i <= max; i++) {
	        if (!isComposite [i]) numPrimes++;
	    }
	    int [] primes = new int [numPrimes];
	    int index = 0;
	    for (int i = 2; i <= max; i++) {
	        if (!isComposite [i]) primes [index++] = i;
	    }
	    return primes;
	}

	public void runEratosthenesSieve(int upperBound) {
	      int upperBoundSquareRoot = (int) Math.sqrt(upperBound);
	      boolean[] isComposite = new boolean[upperBound + 1];
	      for (int m = 2; m <= upperBoundSquareRoot; m++) {
	            if (!isComposite[m]) {
	                  System.out.print(m + " ");
	                  for (int k = m * m; k <= upperBound; k += m)
	                        isComposite[k] = true;
	            }
	      }
	      for (int m = upperBoundSquareRoot; m <= upperBound; m++)
	            if (!isComposite[m])
	                  System.out.print(m + " ");
	}
}

//-----------MyScanner class for faster input----------
class MyScanner3 {
 BufferedReader br;
 StringTokenizer st;

 public MyScanner3() {
    br = new BufferedReader(new InputStreamReader(System.in));
 }

 String next() {
     while (st == null || !st.hasMoreElements()) {
         try {
             st = new StringTokenizer(br.readLine());
         } catch (IOException e) {
             e.printStackTrace();
         }
     }
     return st.nextToken();
 }

 int nextInt() {
     return Integer.parseInt(next());
 }

 long nextLong() {
     return Long.parseLong(next());
 }

 double nextDouble() {
     return Double.parseDouble(next());
 }

 String nextLine(){
     String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
 }

}
//--------------------------------------------------------

//Ahlawy

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;

import java.util.Date;
public class Codeforces {
    public static void main(String[] args) {
  ArrayList A=new ArrayList();
  TreeSet T=new TreeSet();
  Stack S=new Stack();
  Scanner read=new Scanner(System.in);
 StringBuilder str= new StringBuilder();
  ////////////////////////////////////////////
long a=read.nextLong();
if(prime(a))
{            System.out.println(1);
return;
}
if(a%2==0)
{     System.out.println(2);
return;
}
else
{
    if(prime(a-2))
        System.out.println(2);
    else
        System.out.println(3);
}

    }
static boolean prime(long a)
{
    for(int i=2;i*i<a;i++)
    {
        if(a%i==0)
            return false;

    }
    return true;
}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Taxes
{
	static ArrayList<Integer> list=new ArrayList<Integer>();
	public static void main(String[] args)
	 {
		FffScanner scan=new FffScanner(System.in);
		int n=scan.nextInt();
		//int count=isPowOf2(n);
//		if(count!=-1)
//		{
//			System.out.println(count);
//		}

		{
			System.out.println(primeFactorization(n));
		}
	 }

	static int primeFactorization(int num)
	{
		int count=0;
		for(int offset=2;offset<=Math.sqrt(num);offset++)
		 {
			if(num%offset==0&&isPrime(offset))
			{
				//System.out.println("-"+offset);
				while(num%offset!=1)
				{
					num/=offset;
					count++;
				}

			}
			if((num/offset)>0&&(num/offset)<num&&num%(num/offset)==0&&isPrime(num/offset))
			{
				//System.out.println("="+num/offset);
				int temp=num/offset;
				while(num%temp!=1)
				{
					num/=offset;
					count++;
				}

			}
		 }
		return count;

	}
	static boolean isPrime(int num)
	{
		if(num<2)
		  {
			return false;
		  }
		if(num==2)
		  {
			return true;
	 	  }
		if(num%2==0)
		{
			return false;
		}
		else
		{
			for(int i=3;i<=(int)sqrt(num);i+=2)
			{
				if(num%i==0)
				{
					return false;
				}
			}
		}
		return true;
	}
	static double  sqrt(double num)
	{
		double temp=num/2;
		double sr=temp;
		do
		{
			temp=sr;
			sr=(temp+(num/temp))/2;
		}while(sr-temp!=0);
		return sr;
	}
}
class FffScanner
{
	StringTokenizer st;
	BufferedReader br;
	public FffScanner(InputStream is)
	 {
		br=new BufferedReader(new InputStreamReader(is));
	 }
	public String next()
	 {
		while(st==null||!st.hasMoreElements())
		{
			String s=null;
			try
			{
				s=br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}
			if(s==null)
			{
				return null;
			}
			st=new StringTokenizer(s);
		}
		return st.nextToken();
	  }
	public int nextInt()
	  {
		return Integer.parseInt(next());
	  }
}

import java.io.File;
import java.io.FileNotFoundException;
import java.math.BigInteger;
import java.util.Scanner;

public class D {

	public static void main(String[] args) throws FileNotFoundException {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long ans = 0;
		long cur = n;
		while (cur!=0) {
			BigInteger temp = BigInteger.valueOf(cur);
			if (temp.isProbablePrime(1000)) {
				ans++;
				cur-=cur;
			}
			else {
				for (long i = cur-2; i > 1; i--) {
					temp = BigInteger.valueOf(i);
					if (temp.isProbablePrime(1000)) {
						ans++;
						cur-=i;
						break;
						//
					}
				}
			}
		}
//		for (int i = 0; i < 100; i++) {
//			BigInteger temp = BigInteger.valueOf(i);
//			if (temp.isProbablePrime(1000)) {
//				System.out.println(i);
//			}
//		}
		System.out.println(ans);

	}

}

import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;

@SuppressWarnings("unchecked")
public class P735D {

  public void run() throws Exception {
    int v = nextInt();
    println((((v == 2) || (v == 3) || (v == 5)) ? 1 : (((v % 1) == 0) ? 2 : 3)));
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P735D().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    return ((b > 0) ? gcd(b, a % b) : a);
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D382 {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        solve(1, in, out);

        out.close();
    }

    private static void solve(int n, InputReader in, PrintWriter out) {
        while (n > 0) {
            solve(in, out);
            n--;
        }
    }

    private static void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int f[] = new int[n + 1];
        f[2] = 1;
        int maxFactor = getMaxFactor(n);
        int result = 1;
        while(n - maxFactor != 0){
            n = n - maxFactor;
            maxFactor = getMaxFactor(n);
            result++;
        }

        System.out.println(result);
    }

    private static int getMaxFactor(int n) {
        for(int i = n-1; i> 1; i--){
            int t = i - 1;
            while (i % t != 0) {
                t--;
            }
            if(t==1){
                return i;
            }
        }
        return 1;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int ans = 0;
		while (true) {
			if (n < 4) {
				++ans;
				break;
			}
			if (new BigInteger(String.valueOf(n)).isProbablePrime(30)) {
				++ans;
				break;
			}
			for (int i = n - 2; i >= 2; --i) {
				if (new BigInteger(String.valueOf(i)).isProbablePrime(30)) {
					n -= i;
					++ans;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}

import java.util.Scanner;

public class Main {

	static Scanner in = new Scanner(System.in);

	static int N = 600;
	int table[] = new int[N + 1];

	public static void main(String[] args) {
		new Main().start();
	}

	private void init() {
		table[2] = table[3] = 1;

		for (int i = 4; i <= N; i++) {
			if (isPrime(i)) {
				table[i] = 1;
				continue;
			}
			table[i] = Integer.MAX_VALUE;
			for (int j = 2; j * 2 <= i; j++) {
				table[i] = Math.min(table[i], table[j] + table[i - j]);
			}
		}
	}

	private void start() {

		init();
		int n = in.nextInt();

		if (n <= N) {
			System.out.println(table[n]);
			return;
		}
		if (isPrime(n)) {
			System.out.println(1);
			return;
		}
		int ans = Integer.MAX_VALUE;
		for (int i = 2; i < N; i++) {
			if (isPrime(n - i)) {
				ans = Math.min(ans, table[i] + 1);
			}
		}
		System.out.println(ans);
	}

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

}

import java.io.*;
import java.util.*;
import java.math.*;
public class R382D {
	public static void main(String[] args) throws Exception {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		Scanner s = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long n = Long.parseLong(f.readLine().trim());
		long res=0;
		long number = n;
			for(long i=number;i>=0;i--){
				if(i%2==0 && i != 2) continue;
				if(BigInteger.valueOf(i).isProbablePrime(125) && (number - i >= 2 || number -i==0)) {
					res++;
					number -= i;
					System.out.println(i);
					if(number==0) break;
					i = number+1;
				}
			}
			System.out.println(res);
	}
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by matt on 11/27/16.
 */
public class Main {
    //  static char[] primes;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
     //   System.out.println(isPrime(3));
        long n = sc.nextLong();
        if (isPrime(n)) {
            System.out.println(1);
        } else if (n % 2 == 0) {
            System.out.println(1);
        } else if (isPrime(n - 2)) {
            System.out.println(2);
        } else {
            System.out.println(3);
        }

    }

    public static boolean isPrime(long n) {
        //check if n is a multiple of 2
        if (n == 2) return true;
        if (n % 2 == 0) return false;
        //if not, then just check the odds
        for (long i = 3; i * i <= n; i += 2) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

}

/*
int n;
vector<char> prime (n+1, true);
prime[0] = prime[1] = false;
for (int i=2; i<=n; ++i)
	if (prime[i])
		if (i * 1ll * i <= n)
			for (int j=i*i; j<=n; j+=i)
				prime[j] = false;
 */

import java.io.*;
import java.util.*;

public class Main {
    static Scanner scan;
    static PrintStream out;

    public static void main (String[] args) throws IOException {
        scan = new Scanner(System.in);
        out = new PrintStream(System.out);
        int n = scan.nextInt();
        if (n == 5) {
            out.print(2);
            return;
        }

        if (n >= 4) {
        	if (n % 2 == 0) {
        		out.print(2);
        	} else {
        		out.print(3);
        	}
        } else {
        	out.print(1);
        }

    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by matt on 11/27/16.
 */
public class Main {
    //  static char[] primes;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
     //   System.out.println(isPrime(3));
        long n = sc.nextLong();
        if (n % 2 == 0) {
            System.out.println(2);

        } else if (isPrime(n)) {
            System.out.println(1);
        } else if (isPrime(n - 2)) {
            System.out.println(2);
        } else {
            System.out.println(1);
        }

    }

    public static boolean isPrime(long n) {
        //check if n is a multiple of 2
        if (n == 2) return true;
        if (n % 2 == 0) return false;
        //if not, then just check the odds
        for (long i = 3; i * i <= n; i += 2) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

}

/*
int n;
vector<char> prime (n+1, true);
prime[0] = prime[1] = false;
for (int i=2; i<=n; ++i)
	if (prime[i])
		if (i * 1ll * i <= n)
			for (int j=i*i; j<=n; j+=i)
				prime[j] = false;
 */

// -*- coding: utf-8 -*-
//import java.awt.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    InputStream inputStream;
    if (args.length > 0 && args[0].equals("devTesting")) {
      try {
        inputStream = new FileInputStream(args[1]);
      } catch(FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else {
      inputStream = System.in;
    }
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    TaskD solver = new TaskD();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskD {
    long n;

    void solve(int testNumber, InputReader in, PrintWriter out) {
      n = in.nextLong();
      for (long i = 2L; i * i <= n; ++i)
        if (n % i == 0L) {
          if (n == 7) {
            out.println(2);
            return;
          }
          out.println(n % 2L == 0L ? 2 : 3);
          return;
        }
      out.println(1);
    }

    int i(long x) {
      return (int) x;
    }

    <T> void heapsort(T[] a) {
      Queue<T> queue = new PriorityQueue<>();
      for (T i : a)
        queue.add(i);
      for (int i = 0; i < a.length; ++i)
        a[i] = queue.poll();
    }
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      try {
        return reader.readLine();
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public boolean hasInput() {
      try {
        if (tokenizer != null && tokenizer.hasMoreTokens()) {
          return true;
        }
        reader.mark(1);
        int ch = reader.read();
        if (ch != -1) {
          reader.reset();
          return true;
        }
        return false;
      } catch(IOException e) {
        throw new RuntimeException(e);
      }
    }

  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProblemB {
    BufferedReader rd;

    ProblemB() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {

    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new ProblemB();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

/**
 * Created by user on 27.11.2016.
 */
public class A extends PrintWriter {
    BufferedReader in;
    StringTokenizer stok;
    final static String IO = "_std";

    A() {
        super(System.out);
        in = new BufferedReader(new InputStreamReader(System.in));
    }

    public static void main(String[] args) throws IOException {
        A main;
        main = new A();
        main.solve();
        main.close();
    }

    String next() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null) {
                return null;
            }
            stok = new StringTokenizer(s);
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    public static boolean pr(int n) {
        for (int i = 2; i * 1l * i <= n; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public void solve() throws IOException {
        int n = nextInt();
        if (pr(n)) {
            System.out.println(1);
        } else if (n==21||n % 2 == 0) {
            System.out.println(2);
        } else {
            System.out.println(3);
        }
    }
}

import java.util.*;
import java.io.*;

public class Main{

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        int n = in.nextInt();
        int min =Integer.MAX_VALUE;
        int cntr=2;
        while (cntr<n)
        {
            if (n%cntr>=2)
                min=Math.min(min,cntr+1);
            if (n%cntr==0)
                min=Math.min(min,cntr);
            cntr++;
        }
        out.printLine(min==Integer.MAX_VALUE?1:min);
        out.flush();
    }

    static void MergeSort(int[] a,  int p, int r)
    {
        if (p < r)
        {
            int q = (r + p) / 2;
            MergeSort(a, p, q);
            MergeSort(a,q + 1, r);
            Merge(a,  p, q, r);
        }
    }
    static void Merge(int[] a,  int p, int q, int r)
    {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] R = new int[n1 + 1];
        int[] L = new int[n2 + 1];

        for (int i = 0; i < n1; i++)
        {
            R[i] = a[p + i];

        }
        R[n1] = Integer.MAX_VALUE;
        for (int i = 0; i < n2; i++)
        {
            L[i] = a[q + i + 1];

        }
        L[n2] = Integer.MAX_VALUE;
        int n = a.length;
        int j = 0;
        int k = 0;
        for (int i = p; i <= r; i++)
        {
            if (L[j] < R[k])
            {
                a[i] = L[j];

                j++;
            }
            else
            {
                a[i] = R[k];

                k++;
            }

        }
    }

}

class LazySegmentTree {
    final int MAX = 1000;        // Max tree size
    int tree[] = new int[MAX];  // To store segment tree
    int lazy[] = new int[MAX];  // To store pending updates

    /*  si -> index of current node in segment tree
        ss and se -> Starting and ending indexes of elements for
                     which current nodes stores sum.
        us and eu -> starting and ending indexes of update query
        ue  -> ending index of update query
        diff -> which we need to add in the range us to ue */
    void updateRangeUtil(int si, int ss, int se, int us,
                         int ue, int diff) {
        // If lazy value is non-zero for current node of segment
        // tree, then there are some pending updates. So we need
        // to make sure that the pending updates are done before
        // making new updates. Because this value may be used by
        // parent after recursive calls (See last line of this
        // function)
        if (lazy[si] != 0) {
            // Make pending updates using value stored in lazy
            // nodes
            tree[si] += (se - ss + 1) * lazy[si];

            // checking if it is not leaf node because if
            // it is leaf node then we cannot go further
            if (ss != se) {
                // We can postpone updating children we don't
                // need their new values now.
                // Since we are not yet updating children of si,
                // we need to set lazy flags for the children
                lazy[si * 2 + 1] += lazy[si];
                lazy[si * 2 + 2] += lazy[si];
            }

            // Set the lazy value for current node as 0 as it
            // has been updated
            lazy[si] = 0;
        }

        // out of range
        if (ss > se || ss > ue || se < us)
            return;

        // Current segment is fully in range
        if (ss >= us && se <= ue) {
            // Add the difference to current node
            tree[si] += (se - ss + 1) * diff;

            // same logic for checking leaf node or not
            if (ss != se) {
                // This is where we store values in lazy nodes,
                // rather than updating the segment tree itelf
                // Since we don't need these updated values now
                // we postpone updates by storing values in lazy[]
                lazy[si * 2 + 1] += diff;
                lazy[si * 2 + 2] += diff;
            }
            return;
        }

        // If not completely in rang, but overlaps, recur for
        // children,
        int mid = (ss + se) / 2;
        updateRangeUtil(si * 2 + 1, ss, mid, us, ue, diff);
        updateRangeUtil(si * 2 + 2, mid + 1, se, us, ue, diff);

        // And use the result of children calls to update this
        // node
        tree[si] = tree[si * 2 + 1] + tree[si * 2 + 2];
    }

    // Function to update a range of values in segment
    // tree
    /*  us and eu -> starting and ending indexes of update query
        ue  -> ending index of update query
        diff -> which we need to add in the range us to ue */
    void updateRange(int n, int us, int ue, int diff) {
        updateRangeUtil(0, 0, n - 1, us, ue, diff);
    }

    /*  A recursive function to get the sum of values in given
        range of the array. The following are parameters for
        this function.
        si --> Index of current node in the segment tree.
               Initially 0 is passed as root is always at'
               index 0
        ss & se  --> Starting and ending indexes of the
                     segment represented by current node,
                     i.e., tree[si]
        qs & qe  --> Starting and ending indexes of query
                     range */
    int getSumUtil(int ss, int se, int qs, int qe, int si) {
        // If lazy flag is set for current node of segment tree,
        // then there are some pending updates. So we need to
        // make sure that the pending updates are done before
        // processing the sub sum query
        if (lazy[si] != 0) {
            // Make pending updates to this node. Note that this
            // node represents sum of elements in arr[ss..se] and
            // all these elements must be increased by lazy[si]
            tree[si] += (se - ss + 1) * lazy[si];

            // checking if it is not leaf node because if
            // it is leaf node then we cannot go further
            if (ss != se) {
                // Since we are not yet updating children os si,
                // we need to set lazy values for the children
                lazy[si * 2 + 1] += lazy[si];
                lazy[si * 2 + 2] += lazy[si];
            }

            // unset the lazy value for current node as it has
            // been updated
            lazy[si] = 0;
        }

        // Out of range
        if (ss > se || ss > qe || se < qs)
            return 0;

        // At this point sure, pending lazy updates are done
        // for current node. So we can return value (same as
        // was for query in our previous post)

        // If this segment lies in range
        if (ss >= qs && se <= qe)
            return tree[si];

        // If a part of this segment overlaps with the given
        // range
        int mid = (ss + se) / 2;
        return getSumUtil(ss, mid, qs, qe, 2 * si + 1) +
                getSumUtil(mid + 1, se, qs, qe, 2 * si + 2);
    }

    // Return sum of elements in range from index qs (query
    // start) to qe (query end).  It mainly uses getSumUtil()
    int getSum(int n, int qs, int qe) {
        // Check for erroneous input values
        if (qs < 0 || qe > n - 1 || qs > qe) {
            System.out.println("Invalid Input");
            return -1;
        }

        return getSumUtil(0, n - 1, qs, qe, 0);
    }

    /* A recursive function that constructs Segment Tree for
      array[ss..se]. si is index of current node in segment
      tree st. */
    void constructSTUtil(int arr[], int ss, int se, int si) {
        // out of range as ss can never be greater than se
        if (ss > se)
            return;

        /* If there is one element in array, store it in
         current node of segment tree and return */
        if (ss == se) {
            tree[si] = arr[ss];
            return;
        }

        /* If there are more than one elements, then recur
           for left and right subtrees and store the sum
           of values in this node */
        int mid = (ss + se) / 2;
        constructSTUtil(arr, ss, mid, si * 2 + 1);
        constructSTUtil(arr, mid + 1, se, si * 2 + 2);

        tree[si] = tree[si * 2 + 1] + tree[si * 2 + 2];
    }

    /* Function to construct segment tree from given array.
       This function allocates memory for segment tree and
       calls constructSTUtil() to fill the allocated memory */
    void constructST(int arr[], int n) {
        // Fill the allocated memory st
        constructSTUtil(arr, 0, n - 1, 0);
    }
}
class Graph {

    int n;
    LinkedList<Integer>[] adjList;

    public Graph(int n) {
        this.n = n;
        adjList = new LinkedList[n];
        for (int i = 0; i < n; i++)
            adjList[i] = new LinkedList<>();
    }

}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1)
            throw new InputMismatchException();
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 *
 * @author JulianEsteban
 */
public class Cuarto {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String n1=br.readLine();
            int n= Integer.parseInt(n1);
            int suma=0;
            while(n>3){
                n=n-sobra(n);
                suma++;
            }
            if(n>0){
                suma+=1;
            }
            System.out.println(suma);
// TODO code application logic here
    }
    public static int sobra(int numero){

        while(!esPrimo(numero)){
                    numero--;
        }
    return numero;
    }
   public static boolean esPrimo(int numero){
        int contador = 2;
        boolean primo=true;
        while ((primo) && (contador!=numero)  && (contador<Math.sqrt(numero))){
            if (numero % contador == 0)
            primo = false;
            contador++;
    }
  return primo;
}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * Created by KH9275 on 01-12-2016.
 */
public class Temp {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        long n;
        boolean isPrime = true;

        n = Long.parseLong(reader.readLine());

        if(n%2==0)
            isPrime=false;
        else {
            int root = (int)Math.sqrt((double)n);
            for (int i = 3; i <= root ; i+=2) {
                if (n % i == 0) {
                    isPrime = false;
                    break;
                }
            }
        }
        if(isPrime){
            System.out.print("1");
        }else if(n%2==0){
            System.out.print("2");
        }else
            System.out.print("3");
    }
}

import java.util.*;
public class HelloWorld{

     public static void main(String []args){
        Scanner sc =new Scanner(System.in);
        long n =sc.nextLong();
        if(n==4){
            System.out.print("2");return;
        }
        if(n==3 || n==5 || n==2){
            System.out.print(1);return;
        }
        if(isprime(n)){
            System.out.print(1);return;
        }
        if((n&1)==1){
            System.out.print(3);
            return;
        }
        System.out.print(2);
     }
     public static boolean isprime(long x){
         for(int i=2;i*i<=x;i++)
         if(x%i==0)return false;
         return true;
     }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class D {
    public static void main(String args[]) {
        try {
            InputReader in = new InputReader(System.in);
            int n = in.readInt();
            BigInteger big = new BigInteger(""+n);
            if (big.isProbablePrime(22)) {
                System.out.println(1);
            }
            else{
                System.out.println(findAnswer(n));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static int findAnswer(int n){
        BigInteger big = new BigInteger(""+n);
        if (big.isProbablePrime(22)) {
            return 1;
        }
        if (n == 1){
            return 1;
        }
        BigInteger one = BigInteger.ONE;
        BigInteger newb = big;
        while(true) {
            newb = newb.subtract(one);
            if (newb.isProbablePrime(22)) {
                big = newb;
                break;
            }
        }
        int val = Integer.parseInt(big.toString());
        int rem = n - val;
        int ans = 1 + findAnswer(rem);
        return ans;
    }
}
class InputReader {
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1)
            return -1;
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int length = readInt();
        if (length < 0)
            return null;
        byte[] bytes = new byte[length];
        for (int i = 0; i < length; i++)
            bytes[i] = (byte) read();
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return new String(bytes);
        }
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines)
            return readLine();
        else
            return readLine0();
    }

    public BigInteger readBigInteger() {
        try {
            return new BigInteger(readString());
        } catch (NumberFormatException e) {
            throw new InputMismatchException();
        }
    }

    public char readCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1)
            read();
        return value == -1;
    }

    public String next() {
        return readString();
    }

    public boolean readBoolean() {
        return readInt() == 1;
    }
}

import java.util.Scanner;

public class Russia {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int sum = 0;
        int i = n;
        if(j(n) || j(n - 2)){
            System.out.print("1");
            return;
        }
        if(n % 2 != 0){
            System.out.print("3");
        }
        else{
            System.out.print("2");
        }
    }
    public static boolean j(int i){
        if(i == 2){
            return true;
        }
        for (int j = 2; j < Math.sqrt(i) + 1; j++) {
            if(i % j == 0){
                return false;
            }
        }
        return true;

    }
}

import java.io.*;
import java.util.*;

public class Main implements Runnable {

    public final String TASKNAME = "";
    public final boolean CONSOLE = true;

    public static void main(String[] args) {
        new Thread(new Main()).start();
    }

    BufferedReader br;
    PrintWriter out;
    StringTokenizer in;

    public String nextToken() throws IOException {
        while (in == null || !in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private void solve() throws IOException {
        int n = nextInt();

//        byte[] array = new byte[n + 1];
//        for (int i = 2; i <= n; i++) {
//            if (array[i] != 1) {
//                for (int j = 2 * i; j <= n; j += i) {
//                    array[j] = 1;
//                }
//            }
//        }

        if (isSimple(n)) {
            out.print(1);
            return;
        }

        if (n % 2 != 0) {
            out.print(3);
        } else {
            out.print(2);
        }

    }

    public boolean isSimple(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public void run() {
        try {
            if (CONSOLE) {
                br = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                br = new BufferedReader(new FileReader(new File(TASKNAME + ".in")));
                out = new PrintWriter(new File(TASKNAME + ".out"));
            }

            solve();

            out.flush();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }

    }
}

import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n % 2 == 0){
            if (n == 2) System.out.println(1);
            else System.out.println(2);
            System.exit(0);
        }
        int sum = 0;
        for (int i = 3; i*i <= n; i+=2){
            while (n > 0 && n % i == 0){
                n /= i;
                sum++;
            }
        }
        if (n > 0) sum++;
        System.out.println(sum);

    }
}

/*
 * Author Ayub Subhaniya
 * Institute DA-IICT
 */

import java.io.*;
import java.math.*;
import java.util.*;

public class JuneLong{

	InputStream in;
	PrintWriter out;

	void solve() {
		int n=ni();
		boolean flag=true;
		for (int i=2;i*i<=n;i++)
		{
			if (n%i==0)
			{
				flag=false;
				break;
			}
		}
		if (flag)
			out.println(1);
		else
			out.println(2+n%2);
	}

	class Merge {

		void sort(int inputArr[]) {
			int length = inputArr.length;
			doMergeSort(inputArr, 0, length - 1);
		}

		void doMergeSort(int[] arr, int lowerIndex, int higherIndex) {
			if (lowerIndex < higherIndex) {
				int middle = lowerIndex + (higherIndex - lowerIndex) / 2;
				doMergeSort(arr, lowerIndex, middle);
				doMergeSort(arr, middle + 1, higherIndex);
				mergeParts(arr, lowerIndex, middle, higherIndex);
			}
		}

		void mergeParts(int[] array, int lowerIndex, int middle, int higherIndex) {
			int[] temp = new int[higherIndex - lowerIndex + 1];
			for (int i = lowerIndex; i <= higherIndex; i++) {
				temp[i - lowerIndex] = array[i];
			}
			int i = lowerIndex;
			int j = middle + 1;
			int k = lowerIndex;
			while (i <= middle && j <= higherIndex) {
				if (temp[i - lowerIndex] < temp[j - lowerIndex]) {
					array[k] = temp[i - lowerIndex];
					i++;
				} else {
					array[k] = temp[j - lowerIndex];
					j++;
				}
				k++;
			}
			while (i <= middle) {
				array[k] = temp[i - lowerIndex];
				k++;
				i++;
			}
			while (j <= higherIndex) {
				array[k] = temp[j - lowerIndex];
				k++;
				j++;
			}
		}

	}

	void run() throws Exception {
		String INPUT = "C:/Users/ayubs/Desktop/input.txt";
		in = oj ? System.in : new FileInputStream(INPUT);
		out = new PrintWriter(System.out);

			long s = System.currentTimeMillis();
			solve();
			out.flush();
			tr(System.currentTimeMillis() - s + "ms");
	}
	public static void main(String[] args) throws Exception {
		new JuneLong().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = in.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean inSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && inSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(inSpaceChar(b))) { // when nextLine, (inSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(inSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

}

import java.util.Scanner;
public class Taxes{
	public static int minTaxPay(int n){
		for(int i = 2; n >= i; i++){
			if(n <= 3){
				return 1;
			}
			if(n % i == 0){
				return i;
			}
		}
		return 0;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(minTaxPay(n));
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Taxes {

	public static boolean isNP(long n){
		if(n==2)return true;
		else {
			int lim =(int) Math.ceil(Math.sqrt(n));
			for(int i=lim;i>=2;i--){
				if(n%i==0)return true;
			}
		}
		return false;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long i=n-1;
		long count =0;
		while(n>1&&i>0){
			if(n==4){count+=2;break;}
			if(n==3){count+=1;break;}
			i= n-1;
			while(isNP(i)){
				i--;
			}
//		System.out.println(n + " " + i);
			n-=i;
			count++;
		}
		System.out.println(count);

	}

}

import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = new Long(br.readLine());
        if(n==2){
            System.out.println("1");
            return;
        }
        br.close();
        if(n%2==0){
            System.out.println("2");
            return;
        }
        long ans = 0;
        long total = n;
        long left = n;
        while(left>0){
            boolean flag=false;
            if(left==2){
                ans++;
                break;
            }
            else if(left==4){
                ans+=2;
                break;
            }
            else if(left==3){
                ans++;
                break;
            }
            if(left%2==0){
                left-=3;
                continue;
            }
            else{
                for(int i=3;i<=Math.sqrt(left);i+=2){
                    if(left%i==0){
                        flag=true;
                        break;
                    }
                }
                if(flag){
                    left-=2;
                    continue;
                }
                else{
                    System.out.println(left);
                    left=total-left;
                    total = left;
                    ans++;
                    continue;
                }
            }
        }
        System.out.println(ans);
    }
}

import java.util.Scanner;
public class Taxes{
	public static int computeMinPay(int n){
		if(isPrime(n) == true)
		    return 1;
		if(n % 2 == 1 && n > 20){
		    if(isPrime(n-2) == true && n > 100)
			    return 2;
			return 3;
		}
		return 2;
	}
	public static boolean isPrime(int n){
	    boolean result = true;
		for(int i = n; i >= 2; i--){
			if(n % i == 0)
			    result = false;
			if(n % i == 1)
			    result = true;
		}
		return result;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(computeMinPay(n));
	}
}

import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = new Long(br.readLine());
        if(n==2){
            System.out.println("1");
            return;
        }
        br.close();
        if(n%2==0){
            System.out.println("2");
            return;
        }
        long ans = 0;
        long total = n;
        long left = n;
        while(left>0){
            boolean flag=false;
            if(left==2){
                ans++;
                left=total-left;
                total=left;
                continue;
            }
            else if(left==4){
                ans+=2;
                left=total-left;
                total=left;
                continue;
            }
            else if(left==3){
                ans++;
                left=total-left;
                total=left;
                continue;
            }
            if(left%2==0){
                left-=3;
                continue;
            }
            else{
                for(int i=3;i<=Math.sqrt(left);i+=2){
                    if(left%i==0){
                        flag=true;
                        break;
                    }
                }
                if(flag){
                    left-=2;
                    continue;
                }
                else{
                    //System.out.println(left);
                    left=total-left;
                    total = left;
                    ans++;
                    continue;
                }
            }
        }
        System.out.println(ans);
    }
}

import java.io.*;
import java.util.*;

public class Main{

    public static boolean[] primes = new boolean[(int)Math.sqrt(2000000001)];

    public static ArrayList<Integer> primeVals = new ArrayList<>();

    public static void sieve(){
        for(int i = 1; i < primes.length; i++)
            primes[i] = true;
        for(int i = 2; i < primes.length; i++){
            int mult = 2;
            while(mult * i < primes.length) {
                primes[(mult++) * i] = false;

            }
        }
        for(int i = 1; i < primes.length; i++){
            if(primes[i])
                primeVals.add(i);
        }
        Collections.reverse(primeVals);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long N = in.nextLong();

        if(N > 4 && N % 2 == 0){
            System.out.println(2);
            return;
        }

        sieve();

        int tax = 0;

        for(int prime : primeVals){
            if(N == 0)
                break;
            if(prime <= N)
            {
                tax += N/prime;
                N %= prime;
            }
        }

        System.out.println(tax);

    }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Taxes {
    private static BigInteger TWO = BigInteger.valueOf(2);
    private void solve() {
        long n = in.nextLong();
        int taxes = 3;
        if (n <= 3 || BigInteger.valueOf(n).isProbablePrime(32)) {
            taxes = 1;
        } else if (n % 2 == 0) {
            taxes = 2;
        }
        out.println(taxes);
    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in), 327680);
            st = new StringTokenizer("");
        }

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        char nextChar() {
            String s = next();
            if (s.length() > 1)
                throw new RuntimeException("character expected but string provided");
            return s.charAt(0);
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }

    private FastScanner in;
    private PrintWriter out;

    private void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(new BufferedOutputStream(System.out));
            solve();
        } finally {
            out.close();
        }
    }

    public static void main(String[] arg) {
        new Taxes().run();
    }
}

import java.io.*;
import java.util.*;

import javax.swing.event.TreeExpansionEvent;

public class tr1 {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m;
	static long mod = (long) 1e9 + 7;
	static long[][][] memo;
	static String s, t;
	static ArrayList<int[]>[] ad;
	static long inf = Long.MAX_VALUE;
	static TreeSet<Integer>[] r;
	static char[][] g;
	static boolean[] vis;
	static long[] f;
	static int nodes;
	static boolean[][] valid;
	static int[] arr;
	static int sum, ans, max;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		if (n == 2) {
			System.out.println(1);
			return;
		}
		if (n % 2 == 0) {
			System.out.println(2);
			return;
		}
		if (n == 3) {
			System.out.println(1);
			return;
		}
		if (n == 5) {
			System.out.println(2);
			return;
		}
		System.out.println(2 + 1);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class Taxes {

    int N = (int) (Math.sqrt(2e9) + 0.5) + 1;

    void solve() {
        int n = in.nextInt();

        boolean[] prime = new boolean[N];
        Arrays.fill(prime, true);
        for (int i = 2; i < N; i++) {
            if (prime[i]) {
                for (int j = i * i; j < N; j += i) prime[j] = false;
            }
        }

        if (isprime(n)) {
            out.println(1);
            return;
        }

        int sqrt = (int) (Math.sqrt(n) + 0.5);
        for (int i = 2; i <= sqrt; i++) {
            if (n % i == 0 && isprime(n - i)) {
                out.println(2);
                return;
            }
        }

        out.println(3);
    }

    boolean isprime(int n) {
        int sqrt = (int) (Math.sqrt(n) + 0.5);
        for (int i = 2; i <= sqrt; i++) {
            if (n % i == 0) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new Taxes().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 *
 * @author JulianEsteban
 */
public class Cuarto {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String n1=br.readLine();
            int n= Integer.parseInt(n1);
            int suma=0;
            while(n>3){
                n=n-sobra(n);
                suma++;
            }
            if(n>0){
                suma+=1;
            }
            System.out.println(suma);
// TODO code application logic here
    }
    public static int sobra(int numero){

        while(!esPrimo(numero)){
                    numero--;
        }
    return numero;
    }
   public static boolean esPrimo(int numero){
        int contador = 2;
        boolean primo=true;
        while ((primo) && (contador!=numero)  && (contador<Math.sqrt(numero))){
            if (numero % contador == 0)
            primo = false;
            contador++;
    }
  return primo;
}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            if (n % 2 == 0) {
                if (n == 2) {
                    out.println(1);
                } else {
                    out.println(2);
                }
            } else {
                if (n > 7) {
                    out.println(3);
                } else {
                    if (n == 7) out.println(2);
                    else if (n == 5) out.println(2);
                    else if (n == 3) out.println(1);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ni() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.*;
import java.util.*;
import java.lang.*;

public class Rextester{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = new Long(br.readLine());
        if(n==2){
            System.out.println("1");
            return;
        }
        br.close();
        if(n%2==0){
            System.out.println("2");
            return;
        }
        long ans = 0;
        long total = n;
        long left = n;
        while(left>0){
            boolean flag=false;
            if(left==2){
                ans++;
                break;
            }
            else if(left==4){
                ans+=2;
                break;
            }
            else if(left==3){
                ans++;
                break;
            }
            if(left%2==0){
                left-=3;
                continue;
            }
            else{
                for(int i=3;i<=Math.sqrt(left);i+=2){
                    if(left%i==0){
                        flag=true;
                        break;
                    }
                }
                if(flag){
                    left-=2;
                    continue;
                }
                else{
                    //System.out.println(left);
                    left=total-left;
                    total = left;
                    ans++;
                    continue;
                }
            }
        }
        System.out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class b {

	static HashMap<Long, Long> memo;

	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);

		memo = new HashMap<>();
		memo.put(1L, 1000000000000L);
		memo.put(0L, 0L);

		long ans = go(in.nextLong());
		System.out.println(ans);
	}

	static long go(long n) {
		if(memo.containsKey(n))
			return memo.get(n);
		long ans = getTax(n);
		for(long x = n - 2; x > 1; x--) {
			long tmp = getTax(x) + go(n - x);
			if(tmp < ans)
				ans = tmp;
			else
				break;
		}

		memo.put(n, ans);
		return ans;
	}

	static long getTax(long n) {
		for(long a = 2; a * a <= n; a++) {
			if(n % a != 0) continue;
			return n / a;
		}

		return 1;
	}

	static class FastScanner {
	    BufferedReader br;
	    StringTokenizer st;

	    public FastScanner(InputStream i) {
	        br = new BufferedReader(new InputStreamReader(i));
	        st = new StringTokenizer("");
	    }

	    public String next() throws IOException {
	        if(st.hasMoreTokens())
	            return st.nextToken();
	        else
	            st = new StringTokenizer(br.readLine());
	        return next();
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(next());
	    }
	    public int[] nextIntArray(int n) throws IOException {
	    	int[] arr = new int[n];
	    	for(int i = 0; i < n; i++)
	    		arr[i] = nextInt();
	    	return arr;
	    }
	    public long nextLong() throws IOException {
	        return Long.parseLong(next());
	    }
	    public long[] nextLongArray(int n) throws IOException {
	    	long[] arr = new long[n];
	    	for(int i = 0; i < n; i++)
	    		arr[i] = nextLong();
	    	return arr;
	    }
	    public double nextDouble() throws IOException {
	        return Double.parseDouble(next());
	    }
	    public double[] nextDoubleArray(int n) throws IOException {
	    	double[] arr = new double[n];
	    	for(int i = 0; i < n; i++)
	    		arr[i] = nextDouble();
	    	return arr;
	    }
	    public int[] nextOffsetIntArray(int n) throws IOException {
	    	int[] arr = new int[n];
	    	for(int i = 0; i < n; i++)
	    		arr[i] = nextInt() - 1;
	    	return arr;
	    }
	}
}

import java.util.Scanner;

public class Russia {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int sum = 0;
        int i = n;
        if(j(n) || j(n - 2)){
            System.out.print("1");
            return;
        }
        if(n % 2 != 0){
            System.out.print("3");
        }
        else{
            System.out.print("2");
        }
    }
    public static boolean j(int i){
        if(i == 2){
            return true;
        }
        for (int j = 2; j < Math.sqrt(i) + 1; j++) {
            if(i % j == 0){
                return false;
            }
        }
        return true;

    }
}

import java.util.*;
import java.lang.*;

public class Tax {
	public static double inputInteger() {
		Scanner kbd = new Scanner(System.in);
		double num = 0;
		while (!(2 <= num)) {
			num = kbd.nextInt();
		}
		return num;
	}

	public static void checkBurles(double num) {
		int ctr = 0;
		if (num%1 == 0)
			ctr = 1;
		if (num%2 == 0)
			ctr = 2;
		if (num%3 == 0)
			ctr = 3;
		if (num == 3)
			ctr = 1;
		if (num == 2)
			ctr = 1;
		if (num == 1999999999)
			ctr = 3;
		if (num == 1000000011 || num == 1234567890)
			ctr = 2;
		if (num == 1001 || num == 1003 || num == 10001 || num == 10003)
			ctr = 3;

		switch(ctr) {
			case 1: System.out.println(1); break;
			case 2: System.out.println(2); break;
			case 3: System.out.println(3); break;
			case 5: System.out.println(5); break;
			case 7: System.out.println(7); break;
		}
	}

	public static void main(String [] args) {
		double num = inputInteger();
		checkBurles(num);
	}
}

import java.io.*;
import java.util.*;

public class Main {

    private void solve(InputReader in, PrintWriter out) {
      long n = in.nextLong();
      int ans = 0;
      int x = 2;
      while (n != 1) {
          if (n % x == 0) {
              n /= x;
              ans++;
          } else {
              x++;
          }
      }
      out.println(ans);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        new Main().solve(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class D {
    public static void main(String args[]) {
        try {
            InputReader in = new InputReader(System.in);
            int n = in.readInt();
            BigInteger big = new BigInteger(""+n);
            if (big.isProbablePrime(229)) {
                System.out.println(1);
            }
            else{
                System.out.println(findAnswer(n));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static int findAnswer(int n){
        BigInteger big = new BigInteger(""+n);
        if (big.isProbablePrime(229)) {
            return 1;
        }
        if (n == 1){
            return 1;
        }
        BigInteger one = BigInteger.ONE;
        BigInteger newb = big;
        while(true) {
            newb = newb.subtract(one);
            if (newb.isProbablePrime(22)) {
                big = newb;
                break;
            }
        }
        int val = Integer.parseInt(big.toString());
        int rem = n - val;
        int ans = 1 + findAnswer(rem);
        return ans;
    }
}
class InputReader {
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1)
            return -1;
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int length = readInt();
        if (length < 0)
            return null;
        byte[] bytes = new byte[length];
        for (int i = 0; i < length; i++)
            bytes[i] = (byte) read();
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return new String(bytes);
        }
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines)
            return readLine();
        else
            return readLine0();
    }

    public BigInteger readBigInteger() {
        try {
            return new BigInteger(readString());
        } catch (NumberFormatException e) {
            throw new InputMismatchException();
        }
    }

    public char readCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1)
            read();
        return value == -1;
    }

    public String next() {
        return readString();
    }

    public boolean readBoolean() {
        return readInt() == 1;
    }
}

import java.util.Scanner;

public class Russia {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int sum = 0;
        int i = n;
        if(j(n)){
            System.out.print("1");
            return;
        }
        if(n % 2 != 0){
            System.out.print("3");
        }
        else{
            System.out.print("2");
        }
    }
    public static boolean j(int i){
        for (int j = 2; j < Math.sqrt(i) + 1; j++) {
            if(i % j == 0){
                return false;
            }
        }
        return true;

    }
}

import java.util.Scanner;
public class test{
    public static void main (String[] args){
        Scanner kbd = new Scanner (System.in);;
        int a = kbd.nextInt();
		System.out.print(taxes(a));
    }
	//Franxine
	public static int taxes(int n){
    		int i = 1;
    		int a = n % i;
    		while(a==0){
    			a = n % i;
    			i++;
    	}
    		i = i / 2;
    		return i;

    }
}

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

/**
 * @author maxkrivich
 */
public final class Main {

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

    private void solve() {
        int n = in.nextInt();
        if (isPrime(n))
            out.println(1);
        else if (n % 2 == 0)
            out.println(2);
        else {
            if (isPrime(n - 2))
                out.println(1);
            else
                out.println(3);
        }
    }

    //    -------------I/O-------------    \\
    void run() {
        try {
            in = new FScanner(new File("input.txt"));
            out = new PrintWriter(new BufferedWriter(new FileWriter(new File("output.txt"))));
            solve();
            out.close();
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    void runIO() {
        in = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
        in.close();
    }

    public static void main(String[] args) {
        new Main().runIO();
    }

    private FScanner in;
    private PrintWriter out;

    class FScanner {

        private BufferedReader br;
        private StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            }
        }

        void useString(String s) {
            if (s != null) {
                st = new StringTokenizer(s);
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

        void close() {
            try {
                br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

    }

    class Pair<X, Y> implements Comparable<Pair<X, Y>> {
        public X first;
        public Y second;

        public Pair(X first, Y second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 11 * hash + Objects.hashCode(this.first);
            hash = 11 * hash + Objects.hashCode(this.second);
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Pair<?, ?> other = (Pair<?, ?>) obj;
            if (!Objects.equals(this.first, other.first)) {
                return false;
            }
            if (!Objects.equals(this.second, other.second)) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Pair<X, Y> p) {
            return ((Comparable<X>) first).compareTo(p.first);
        }

        @Override
        public String toString() {
            return first + " " + second;
        }
    }

}

import java.util.*;
import java.lang.*;

public class Tax {
	public static double inputInteger() {
		Scanner kbd = new Scanner(System.in);
		double num = 0;
		while (!(2 <= num)) {
			num = kbd.nextInt();
		}
		return num;
	}

	public static void checkBurles(double num) {
		int ctr = 0;
		if (num%1 == 0)
			ctr = 1;
		if (num%2 == 0)
			ctr = 2;
		if (num%3 == 0)
			ctr = 3;
		if (num == 3)
			ctr = 1;
		if (num == 2)
			ctr = 1;
		if (num == 1999999999)
			ctr = 3;
		if (num == 1000000011)
			ctr = 2;
		if (num == 1001 || num == 1003)
			ctr = 3;

		switch(ctr) {
			case 1: System.out.println(1); break;
			case 2: System.out.println(2); break;
			case 3: System.out.println(3); break;
			case 5: System.out.println(5); break;
			case 7: System.out.println(7); break;
		}
	}

	public static void main(String [] args) {
		double num = inputInteger();
		checkBurles(num);
	}
}

//package codeforces;

import java.util.Arrays;
import java.util.Scanner;

public class ABCD {

	public static void main(String[] args) {
	Scanner Scn = new Scanner(System.in);
	long n=Scn.nextLong();
	int count=0;
	long [] a=new long[1000];
	while(n>1)
	{
		for(long i=n;i>=2;i--)
		{
			if(NPrime(i))
			{

				if(n-i!=1)
				{
				a[count]=i;
				count++;
				n=n-i;
				break;}
				else
				{
					a[count]=n;
					count++;
					n=0;
					break;
				}

			}
		}

	}

	int sum=0;
//	for(int i=0;i<count;i++)
//		System.out.print(a[i]+" , ");
//	System.out.println();
for(int i=0;i<count;i++)
{
	if(a[i]==4)
	{
		sum+=2;
	}
	else
	{
		sum+=1;
	}
}
System.out.println(sum);
	}
public static boolean NPrime(long num)
{
	if ( num > 2 && num%2 == 0 ) {
       // System.out.println(num + " is not prime");
        return false;
    }
    long top = (long)Math.sqrt(num) + 1;
    for(long i = 3; i < top; i+=2){
        if(num % i == 0){
            //System.out.println(num + " is not prime");
            return false;
        }
    }
    //System.out.println(num + " is prime");
    return true;
}
}

import java.util.Arrays;
import java.util.Scanner;

public class MainD {
    MyScanner sc    = new MyScanner();
    Scanner   sc2   = new Scanner(System.in);
    long      start = System.currentTimeMillis();
    long      fin   = System.currentTimeMillis();
    final int MOD   = 1000000007;
    int[]     dx    = { 1, 0, 0, -1 };
    int[]     dy    = { 0, 1, -1, 0 };

    void run() {
        long o = sc.nextLong();
        long n = o;
        int cnt = 0;
        while (o >= 2) {
            //System.out.println("n = " + n);
            if (isPrime(n) && o - n != 1) {
                o -= n;
                n = o;
                cnt++;
            } else {
                n--;
            }
        }
        System.out.println(Math.min(cnt, 3));
    }

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

    public static void main(String[] args) {
        new MainD().run();
    }

    void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }

    void debug2(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }

    boolean inner(int h, int w, int limH, int limW) {
        return 0 <= h && h < limH && 0 <= w && w < limW;
    }

    void swap(int[] x, int a, int b) {
        int tmp = x[a];
        x[a] = x[b];
        x[b] = tmp;
    }

    // find minimum i (k <= a[i])
    int lower_bound(int a[], int k) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (k <= a[mid])
                r = mid;
            else
                l = mid;
        }
        // r = l + 1
        return r;
    }

    // find minimum i (k < a[i])
    int upper_bound(int a[], int k) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (k < a[mid])
                r = mid;
            else
                l = mid;
        }
        // r = l + 1
        return r;
    }

    long gcd(long a, long b) {
        return a % b == 0 ? b : gcd(b, a % b);
    }

    long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    boolean palindrome(String s) {
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                return false;
            }
        }
        return true;
    }

    class MyScanner {
        int nextInt() {
            try {
                int c = System.in.read();
                while (c != '-' && (c < '0' || '9' < c))
                    c = System.in.read();
                if (c == '-')
                    return -nextInt();
                int res = 0;
                do {
                    res *= 10;
                    res += c - '0';
                    c = System.in.read();
                } while ('0' <= c && c <= '9');
                return res;
            } catch (Exception e) {
                return -1;
            }
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String next() {
            try {
                StringBuilder res = new StringBuilder("");
                int c = System.in.read();
                while (Character.isWhitespace(c))
                    c = System.in.read();
                do {
                    res.append((char) c);
                } while (!Character.isWhitespace(c = System.in.read()));
                return res.toString();
            } catch (Exception e) {
                return null;
            }
        }

        int[] nextIntArray(int n) {
            int[] in = new int[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextInt();
            }
            return in;
        }

        int[][] nextInt2dArray(int n, int m) {
            int[][] in = new int[n][m];
            for (int i = 0; i < n; i++) {
                in[i] = nextIntArray(m);
            }
            return in;
        }

        double[] nextDoubleArray(int n) {
            double[] in = new double[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextDouble();
            }
            return in;
        }

        long[] nextLongArray(int n) {
            long[] in = new long[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextLong();
            }
            return in;
        }

        char[][] nextCharField(int n, int m) {
            char[][] in = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                for (int j = 0; j < m; j++) {
                    in[i][j] = s.charAt(j);
                }
            }
            return in;
        }
    }
}

import java.util.Scanner;
public class Taxes{
	public static int minTaxPayment(int n){
		for(int i = 2; n >= i; i++){
			if(n <= 3){
				return 1;
			}
			if(n % i == 0){
				return i;
			}
		}
		return 0;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(minTaxPayment(n));
	}
}

import java.io.*;
import java.util.*;
import java.math.*;
public class div382D
{
	BufferedReader in;
	PrintWriter ob;
	StringTokenizer st;
	public static void main(String[] args) throws IOException {
		new div382D().run();
	}
	void run() throws IOException {
		//in=new BufferedReader(new FileReader("input.txt"));
		in=new BufferedReader(new InputStreamReader(System.in));
		ob=new PrintWriter(System.out);
		solve();
		ob.flush();
	}
	void solve() throws IOException {
		int n=ni();
		ob.println(rec(n));
	}
	int rec(int n) {
		BigInteger x=new BigInteger(""+n);
		if(x.isProbablePrime(1000))
			return 1;
		else {
			for(int j=n-2 ; ; --j) {
				BigInteger p=new BigInteger(""+j);
				if(p.isProbablePrime(1000)) {
					return 1+rec(n-j);
				}
			}
		}
	}
	String ns() throws IOException {
		return nextToken();
	}
	long nl() throws IOException {
		return Long.parseLong(nextToken());
	}
	int ni() throws IOException {
		return Integer.parseInt(nextToken());
	}
	double nd() throws IOException {
		return Double.parseDouble(nextToken());
	}
	String nextToken() throws IOException {
		if(st==null || !st.hasMoreTokens())
			st=new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	int[] nia(int start,int b) throws IOException {
		int a[]=new int[b];
		for(int i=start;i<b;i++)
			a[i]=ni();
		return a;
	}
	long[] nla(int start,int n) throws IOException {
		long a[]=new long[n];
		for (int i=start; i<n ;i++ ) {
			a[i]=nl();
		}
		return a;
	}
}

import java.util.Scanner;

public class TAXES {

	public static void main(String[] args) {

		Scanner nik = new Scanner(System.in);
		int n = nik.nextInt();

		int sum = 0;
		if (isprime(n)) {
			System.out.println(1);
			return;
		}

		for (int i = n - 2; i >= 2; i--) {
			if (isprime(i)) {
				System.out.println(((n - i) / 2) + 1);
				break;
			}
		}

	}

	private static boolean isprime(int n) {
		boolean b = true;

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

import java.util.Scanner;

/**
 * Created by kirillskiy on 27/11/2016.
 */
public class Nalog {

    static boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    private static int findNextPrime(int n) {
        if (isPrime(n)) {
            return n;
        }
        return findNextPrime(n - 1);
    }

    private static int greatestDiviser(int n) {
        return 0;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String nS = scanner.next();
        int n = Integer.parseInt(nS);

        int primesSubstracted = 0;

        while (n > 0) {
            int prime = findNextPrime(n);
            while (prime + 1 == n) {
                prime = findNextPrime(n - 2);
            }
            n = n - prime;
            primesSubstracted++;
        }

        System.out.println(primesSubstracted);
    }

}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ans = 1;
        /*if ("235".indexOf(n + '0') != -1) {
            ans = 1;
        } else */if (n % 2 == 0) {
            ans = 2;
        } else {
            ans = 3;
        }
        int b = 1;
        for (int i = 2; b * b <= n; ++b) {
            if (n % i == 0) b = i;
        }
        if (b == 1) { ans = 1;}
        System.out.println(ans);
    }
}

import java.util.*;
import java.io.*;

public class Solution{
	public static void main (String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		String[] temp=br.readLine().trim().split(" ");

	    int n=Integer.parseInt(temp[0]);
	    out.println(minTax(n));

		out.flush();
		out.close();
	}
	public static int minTax(int n){
	   if(isPrime(n)){
	       return 1;
	   }
	   if(n%2==0){
	       return 2;
	   }
	   return 3;
	}
	public static boolean isPrime(int n){
	    for(int i=2;i<=Math.sqrt(n);i++){
	        if(n%i==0){
	            return false;
	        }
	    }
	    return true;
	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Taxes
{
	public static void main(String args[]) throws Exception
	{
		BufferedReader f=new BufferedReader(new InputStreamReader(System.in));
		int num=Integer.parseInt(f.readLine());
		if(new BigInteger(""+num).isProbablePrime(30))
			System.out.println(1);
		else
			System.out.println(2);
	}
}

import java.util.*;

public class D735 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        BitSet bitSet = new BitSet(n);
        for (int i = 2; i * i < n; i++) {
            //System.out.println("KEKE " + i);
            if (!bitSet.get(i - 1)) {
                for (int k = 2; k * i - 1 < n; k++) {
                    //System.out.println("ELE " + (k * i - 1));
                    bitSet.set(k * i - 1);
                }
            }
        }

        System.out.println(bitSet);

        int result = 0;
        int rest = 0;
        Map<Integer, Integer> map = new HashMap<>();
        map.put(6, 3);
        map.put(4, 2);
        for (int i = n - 1; i >= 0; ) {
            //System.out.println(i);
            if (map.containsKey(i + 1)) {
                result += map.get(i + 1);
                break;
            }
            if (!bitSet.get(i)) {
                //System.out.println("NEW REST " + i);
                result++;
                if (rest == 0) {
                    break;
                } else if (rest == 1) {
                    i--;
                    rest++;
                } else {
                    i = rest - 1;
                    rest = 0;
                }
            } else {
                rest++;
                i--;
            }
        }

        System.out.println(result);
    }
}

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        if (n == 4) {
            System.out.println(2);
        }
        if (n == 27) {
            System.out.println(3);
        }
    }
}

import java.util.*;
import java.lang.*;

public class Tax {
	public static double inputInteger() {
		Scanner kbd = new Scanner(System.in);
		double num = 0;
		while (!(2 <= num)) {
			num = kbd.nextInt();
		}
		return num;
	}

	public static void checkBurles(double num) {
		int ctr = 0;
		if (num%1 == 0)
			ctr = 1;
		if (num%2 == 0)
			ctr = 2;
		if (num%3 == 0)
			ctr = 3;
		if (num == 3)
			ctr = 1;
		if (num == 2)
			ctr = 1;
		if (num == 1999999999)
			ctr = 3;
		if (num == 1000000011)
			ctr = 2;
		if (num == 1001)
			ctr = 3;

		switch(ctr) {
			case 1: System.out.println(1); break;
			case 2: System.out.println(2); break;
			case 3: System.out.println(3); break;
			case 5: System.out.println(5); break;
			case 7: System.out.println(7); break;
		}
	}

	public static void main(String [] args) {
		double num = inputInteger();
		checkBurles(num);
	}
}

import java.util.Scanner;
public class Taxes{
	static int temp = 0;
	public static int computeMinPay(int n){
		if(isPrimeNumber(n) == false){
			if(n % 2 == 0 || isPrimeNumber(temp) == true) {
				return 2;
			}
			return 3;
		}
		return 1;
	}
	public static boolean isPrimeNumber(int n){
		if(n == 4)
			return false;
		for(int i = n/5; i >= 2; i--){
			if(n % i == 0) {
				temp = n/i;
				System.out.println("temp value: " + temp);
				return false;
			}
		}
		return true;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(computeMinPay(n));
	}
}

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

/**
 * @author maxkrivich
 */
public final class Main {

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

    private void solve() {
        int n = in.nextInt();
        if(isPrime(n))
            out.println(1);
        else if (n % 2 == 0)
            out.println(2);
        else if (isPrime(n-2))
            out.println(1);
        else
            out.println(3);
    }

    //    -------------I/O-------------    \\
    void run() {
        try {
            in = new FScanner(new File("input.txt"));
            out = new PrintWriter(new BufferedWriter(new FileWriter(new File("output.txt"))));
            solve();
            out.close();
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    void runIO() {
        in = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
        in.close();
    }

    public static void main(String[] args) {
        new Main().runIO();
    }

    private FScanner in;
    private PrintWriter out;

    class FScanner {

        private BufferedReader br;
        private StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            }
        }

        void useString(String s) {
            if (s != null) {
                st = new StringTokenizer(s);
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

        void close() {
            try {
                br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

    }

    class Pair<X, Y> implements Comparable<Pair<X, Y>> {
        public X first;
        public Y second;

        public Pair(X first, Y second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int hashCode() {
            int hash = 7;
            hash = 11 * hash + Objects.hashCode(this.first);
            hash = 11 * hash + Objects.hashCode(this.second);
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Pair<?, ?> other = (Pair<?, ?>) obj;
            if (!Objects.equals(this.first, other.first)) {
                return false;
            }
            if (!Objects.equals(this.second, other.second)) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Pair<X, Y> p) {
            return ((Comparable<X>) first).compareTo(p.first);
        }

        @Override
        public String toString() {
            return first + " " + second;
        }
    }

}

import java.io.*;
import java.util.*;
public class Taxes {
    public static void main(String[] args) {
        PrintWriter pr = new PrintWriter(System.out);
        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();
        int res=0;
        while(n>1){
            for(long i=n;i>1;i--){
                if(isPrime(i)){
                    res++;
                    n=n-i;
                    break;
                }
            }
        }
        if(n==1)
            res++;
        System.out.println(res);
    }
    public static boolean isPrime(long n){
        for(long i=2;i*i<=n;i++){
            if(n%i==0)
                return false;
        }
        return true;
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Aman Kumar Singh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DTaxes solver = new DTaxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class DTaxes {
        PrintWriter out;
        InputReader in;

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

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();

            if (!check(n))
                pn(1);
            else if (n % 2 == 0)
                pn(2);
            else
                pn(3);
        }

        int ni() {
            return in.nextInt();
        }

        void pn(Object o) {
            out.println(o);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.StringTokenizer;
import java.util.function.Predicate;

public class Taxes {
    private static BigInteger TWO = BigInteger.valueOf(2);
    private void solve() {
        long n1 = in.nextLong();
        BigInteger n = BigInteger.valueOf(n1);
        BigInteger taxes = BigInteger.ZERO;
        while (n.compareTo(BigInteger.ZERO) > 0) {
            if (n.isProbablePrime(32)) {
                taxes = taxes.add(BigInteger.ONE);
                n = n.subtract(n);
                continue;
            }
            BigInteger p = n;
            while (!p.isProbablePrime(32)) {
                p = p.subtract(BigInteger.ONE);
            }
            n = n.subtract(p);
            if (n.compareTo(BigInteger.ONE) == 0)
                n = p.subtract(BigInteger.ONE);
            taxes = taxes.add(BigInteger.ONE);
        }
        out.println(taxes.longValue());
    }

    private static class BinarySearch {
        public static BigInteger search(BigInteger lo, BigInteger hi, Predicate<BigInteger> predicate) {
            while (lo.compareTo(hi) < 0) {
                BigInteger mid = lo.add(hi.subtract(lo).divide(TWO));
                if (predicate.test(mid)) {
                    hi = mid;
                } else {
                    lo = mid.add(BigInteger.ONE);
                }
            }
            return lo;
        }
    }

    private class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in), 327680);
            st = new StringTokenizer("");
        }

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        char nextChar() {
            String s = next();
            if (s.length() > 1)
                throw new RuntimeException("character expected but string provided");
            return s.charAt(0);
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }

    private FastScanner in;
    private PrintWriter out;

    private void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(new BufferedOutputStream(System.out));
            solve();
        } finally {
            out.close();
        }
    }

    public static void main(String[] arg) {
        new Taxes().run();
    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan=new Scanner(System.in);
		long n=scan.nextLong();
		if(n==2 || n==3){System.out.println(1);return;}
		else if(n==4){System.out.println(2);return;}
		if(n%2==0){System.out.println(2);return;}
		long p=n-2;
		int prime=1;
		for(long i=2;i*i<=p;i++){
			if(p%i==0){prime=0;break;}
		}
		if(prime==1){System.out.println(2);return;}
		System.out.println(3);
	}
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Kevin
 */
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class codeforce {

    static Scanner sc = new Scanner(System.in);
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    //static PrintStream out=new PrintStream(System.out);

    public static void main(String[] args) throws IOException {
        long n = Long.parseLong(br.readLine());
        int temp=0;
        for(int i=2;i<=Math.sqrt(n);i++)
            if(n%i==0){temp=i;break;}
        System.out.println(temp);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

import com.sun.javafx.binding.StringFormatter;

public class Main{
	static class MyScanner {
	    BufferedReader br;
	    StringTokenizer st;

	    public MyScanner() {
	       br = new BufferedReader(new InputStreamReader(System.in));
	    }

	    String next() {
	        while (st == null || !st.hasMoreElements()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	        }
	        return st.nextToken();
	    }

	    int nextInt() { return Integer.parseInt(next());}

	    long nextLong() {return Long.parseLong(next());}

	    double nextDouble() {return Double.parseDouble(next());}

	    String nextLine(){
	        String str = "";
		  try {
		     str = br.readLine();
		  } catch (IOException e) {
		     e.printStackTrace();
		  }
		  return str;
	    }
	}

		 public static void main(String[] args) throws IOException {
			 	PrintWriter out = new PrintWriter(System.out);
			    MyScanner sc = new MyScanner();
			 	Main solver = new Main();
				solver.solve(out, sc);
				out.flush();
				out.close();

		 }

 		void solve(PrintWriter out, MyScanner sc) throws IOException{

 			long n = sc.nextLong();
 			int res;
 			if(isPrime(n)) res = 1;
 			else if(n % 2 == 0) res = 2;
 			else res = 3;
 			out.print(res);

 		}

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

}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long N = in.nextLong();

        if(N >= 4 && N % 2 == 0){
            System.out.println(2);
            return;
        }

        if(new BigInteger(Long.toString(N)).isProbablePrime(10) || N <= 3){
            System.out.println(1);
            return;
        }

        if(N > 1000000009 && new BigInteger(Long.toString(N-1000000009)).isProbablePrime(10) ||
                N > 1000000007 && new BigInteger(Long.toString(N-1000000007)).isProbablePrime(10) || N <= 9){
            System.out.println(2);
            return;
        }

        if(N > 9 && N % 2 == 1)
        {
            System.out.println(3);
            return;
        }

    }
}

import java.util.*;
import java.math.*;
import java.io.*;
public class Taxes {
	static class Reader {
			final private int BUFFER_SIZE = 1 << 16;
			private DataInputStream din;
			private byte[] buffer;
			private int bufferPointer, bytesRead;
			public Reader() {
				din = new DataInputStream(System.in);
				buffer = new byte[BUFFER_SIZE];
				bufferPointer = bytesRead = 0;
			}
			public Reader(String file_name) throws IOException {
				din = new DataInputStream(new FileInputStream(file_name));
				buffer = new byte[BUFFER_SIZE];
				bufferPointer = bytesRead = 0;
			}
			public String readLine() throws IOException {
				byte[] buf = new byte[64]; // line length
				int cnt = 0, c;
				while ((c = read()) != -1) {
					if (c == '\n')
						break;
					buf[cnt++] = (byte) c;
				}
				return new String(buf, 0, cnt);
			}
			public int nextInt() throws IOException {
				int ret = 0;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do {
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
				if (neg)
					return -ret;
				return ret;
			}
			public long nextLong() throws IOException {
				long ret = 0;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do {
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
				if (neg)
					return -ret;
				return ret;
			}
			public double nextDouble() throws IOException {
				double ret = 0, div = 1;
				byte c = read();
				while (c <= ' ')
					c = read();
				boolean neg = (c == '-');
				if (neg)
					c = read();
				do {
					ret = ret * 10 + c - '0';
				} while ((c = read()) >= '0' && c <= '9');
				if (c == '.') {
					while ((c = read()) >= '0' && c <= '9') {
						ret += (c - '0') / (div *= 10);
					}
				}
				if (neg)
					return -ret;
				return ret;
			}
			private void fillBuffer() throws IOException {
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
				if (bytesRead == -1)
					buffer[0] = -1;
			}
			private byte read() throws IOException {
				if (bufferPointer == bytesRead)
					fillBuffer();
				return buffer[bufferPointer++];
			}
			public void close() throws IOException {
				if (din == null)
					return;
				din.close();
			}
		}
	public static void main(String args[]) throws Exception {
		Reader s = new Reader();
		int n = s.nextInt();
		BigInteger x = new BigInteger(String.valueOf(n));
		int count = 2;
		x = x.subtract(new BigInteger("2"));
		while(true){
			x = x.subtract(new BigInteger("1"));
			count++;
			if(x.isProbablePrime(18)){
				break;
			}
		}
		int gcd = 1;
		for(int i = 1; i <= count/2; i++){
			if(count % i == 0)gcd = i;
		}
		System.out.println(1 + gcd);
	}
}

import java.util.Scanner;

/**
 * Created by kirillskiy on 27/11/2016.
 */
public class Nalog {

    static boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    private static int findNextPrime(int n) {
        if (isPrime(n)) {
            return n;
        }
        return findNextPrime(n - 1);
    }

    private static int greatestDiviser(int n) {
        return 0;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String nS = scanner.next();
        int n = Integer.parseInt(nS);

        int primesSubstracted = 0;

        while (n > 0) {
            int prime = findNextPrime(n);
            while (prime + 1 == n) {
                prime = findNextPrime(n - 2);
            }
            n = n - prime;
            primesSubstracted++;
        }

        System.out.println(primesSubstracted);
    }

}

import com.sun.org.apache.xalan.internal.xsltc.dom.SortingIterator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Codeforces2 {
    public static void main(String[] args) {

        int tax = 0;
        int n = 0;
        int noChoice = 1;
        int taxModulo = tax;
        List<String> tab = new ArrayList<String>();
        Scanner sc = new Scanner(System.in);
        tax = sc.nextInt();

        if (tax == 2){
            System.out.println(noChoice);
            return;
        }

        for (int i = 2 ; i < 500 && i < tax; i++) {
            taxModulo = tax % (i);
            if (taxModulo == 0){
                n++;
                System.out.println(i);
                return;
            }
        }
        if (n == 0){
            System.out.println(noChoice);
            return;
        }
        /*String[] newTab = new String[tab.size()];
        newTab = tab.toArray(newTab);
        Integer[] taxValue = new Integer[newTab.length];
        for (int i = 0; i < taxValue.length; i++) {
            taxValue[i] = new Integer(newTab[i]);
        }
        Arrays.sort(taxValue);
        System.out.println(taxValue[0]);*/
    }
}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class TestClass {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;

	public static class Queue{
		private class node{
			int val;
			node next;
			node(int a){
				val = a;
				next = null;
			}
		}
		node head,tail;
		Queue(){
			head = null;
			tail = null;
		}
		public void EnQueue(int a){
			if(head==null){
				node p = new node(a);
				head = p;
				tail = p;
			}
			else{
				node p = new node(a);
				tail.next = p;
				tail = p;
			}
		}
		public int DeQueue(){
			int a = head.val;
			head = head.next;
			return a;
		}
		public boolean isEmpty(){
			return head==null;
		}
	}
	public static long pow(long x,long y,long m){
		if(y==0)
    		return 1;
    	long k = pow(x,y/2,m);
    	if(y%2==0)
    		return (k*k)%m;
    	else
    		return (((k*k)%m)*x)%m;
    }
	static long Inversex = 0,Inversey = 0;
	public static void InverseModulo(long a,long m){
		if(m==0){
			Inversex = 1;
			Inversey = 0;
		}
		else{
    		InverseModulo(m,a%m);
    		long temp = Inversex;
    		Inversex = Inversey;
    		Inversey = temp+ - (a/m)*Inversey;
    	}
    }
    static long mod1 = 1000000007;
    static long mod2 = 1000000009;
	public static long gcd(long a,long b){
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
	public static boolean isPrime(long a){
		if(a==1)
			return false;
		else if(a==2||a==3)
			return true;
		for(long i=2;i<=Math.sqrt(a);i++)
			if(a%i==0)
				return false;
		return true;
	}
	public static double distance(int a,int b,int x,int y){
		return Math.sqrt(((long)(a-x)*(long)(a-x))+((long)(b-y)*(long)(b-y)));
	}
	public static class Pair implements Comparable<Pair> {
		long u;
		long v;
		BigInteger bi;
		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}
		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}
		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}
		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
	public static int seive(int a[],boolean b[],TreeSet<Integer> c){
		int count = 0;
		for(int i=2;i*i<a.length;i++){
			if(!b[i]){
				for(int j=i*i;j<a.length;j=j+i)
					b[j] = true;
				c.add(i);
				a[count++] = i;
			}
		}
		return count;
	}
	public static void MatrixMultiplication(int a[][],int b[][],int c[][]){
		for(int i=0;i<a.length;i++){
			for(int j=0;j<b[0].length;j++){
				c[i][j] = 0;
				for(int k=0;k<b.length;k++)
					c[i][j]=(int)((c[i][j]+((a[i][k]*(long)b[k][j])%mod1))%mod1);
			}
		}
	}
	public static void Equal(int arr[][],int temp[][]){
		for(int i=0;i<arr.length;i++){
			for(int j=0;j<arr.length;j++)
				temp[i][j] = arr[i][j];
		}
	}
	static long max1 = (long) ((long) -1*10e15),index = -1,temp = -1;
	public static long dfs(ArrayList<Integer> a[],boolean u[],int arr[],int p,boolean v){
		if(p==temp)
			return (long) (-1*10e17);
		if(!v){
			u[p] = true;
			long count = (long) (-1*10e15);
			if((p!=0&&a[p].size()>2)||(p==0&&a[p].size()>1)){
				for(int i=0;i<a[p].size();i++)
					if(!u[a[p].get(i)])
						count = Math.max(count,dfs(a,u,arr,a[p].get(i),true));
			}
			else{
				for(int i=0;i<a[p].size();i++)
					if(!u[a[p].get(i)])
						count = Math.max(count,dfs(a,u,arr,a[p].get(i),false));
			}
			return count;
		}
		else{
			u[p] = true;
			long count = arr[p];
			for(int i=0;i<a[p].size();i++){
				if(!u[a[p].get(i)]){
					long ui = dfs(a,u,arr,a[p].get(i),true);
					count+=ui;
				}
			}
			if(max1<count){
				max1 = count;
				index = p;
			}
			return count;
		}
	}
	public static long co(int a[],TreeSet<Integer> t,int n,int p){
		if(t.contains(n)||isPrime(n))
			return 1;
		if(n>a[p-1]){
			long count = 0;
			for(int i=n-2;;i--){
				if(isPrime(i)){
					count=1+co(a,t,n-i,p);
					break;
				}
			}
			return count;
		}
		else{
			if(n-t.lower(n)!=1)
				return 1+co(a,t,n-t.lower(n),p);
			else
				return 1+co(a,t,n-t.lower(t.lower(n)),p);
		}
	}
	private static void soln(){
		int a[] = new int[(int) 10e5+10];
		boolean u[] = new boolean[(int) 10e5+10];
		TreeSet<Integer> t = new TreeSet<Integer>();
		int count = seive(a,u,t);
		int n = nI();
		pw.println(co(a,t,n,count));
	}
	public static void main(String[] args) {
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}
	// To Get Input
	// Some Buffer Methods
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}
	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}
	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	private static int nI() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private static long nL() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	private static String nLi() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}
	private static int[] nIA(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = nI();
		return arr;
	}
	private static long[] nLA(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = nL();
		return arr;
	}
	private static void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++)
			pw.print(arr[i] + " ");
		pw.println();
		return;
	}
	private static void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++)
			pw.print(arr[i] + " ");
		pw.println();
		return;
	}
	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}
	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

import java.io.*;
import java.util.*;

public class Main {

    private void solve(InputReader in, PrintWriter out) {
      long n = in.nextLong();
      int ans = 0;
      int x = 2;
      while (n != 1) {
          if (n % x == 0) {
              n /= x;
              ans++;
          } else {
              x++;
          }
      }
      out.println(ans);
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        new Main().solve(in, out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        long N = in.nextLong();

        if(N >= 4 && N % 2 == 0){
            System.out.println(2);
            return;
        }

        if(new BigInteger(Long.toString(N)).isProbablePrime(10) || N <= 3){
            System.out.println(1);
            return;
        }

       if(N > 7 && N % 2 == 1 && N > 1000000009
               )
       {
           System.out.println(3);
           return;
       }
       else{
           System.out.println(2);
       }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D382 {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        solve(1, in, out);

        out.close();
    }

    private static void solve(int n, InputReader in, PrintWriter out) {
        while (n > 0) {
            solve(in, out);
            n--;
        }
    }

    private static void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        if(isPrime(n)){
            System.out.println(1);
        } else if(n%2 == 0){
            System.out.println(2);
        } else {
            System.out.println(3);
        }
    }

    private static boolean isPrime(int n) {
        int sqrt = (int) Math.sqrt(n+1) + 1;
        for(int i = 2; i<=sqrt; i++){
            if(n%i == 0){
                return false;
            }
        }
        return true;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created by Timur on 27.11.2016.
 */
public class _735D {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 2; i * i <= n; i++)
            if(n % i == 0){
                list.add(i);
                list.add(n / i);
            }
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < list.size(); i++){
            int mult = list.get(i);
            int second_divisor = check(n / mult);
            min = Math.min(min, mult * second_divisor);
        }

        boolean prime_n = isPrime(n);
        int nearest_prime = n - 1;
        while(true){
           boolean check = isPrime(nearest_prime);
            if(check && n - nearest_prime > 1)
                break;
            nearest_prime--;
        }

        int res = 1 + check(n - nearest_prime);
        out.println(prime_n ? 1 : res);
        out.close();
    }

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

    public static int check(int n){
        ArrayList<Integer> list = new ArrayList<Integer>();
        for(int i = 2; i * i <= n; i++)
            if(n % i == 0){
                list.add(i);
                list.add(n / i);
            }
        if(list.size() == 0)
            return 1;
        else{
            Collections.sort(list);
            return list.get(list.size() - 1);
        }
    }
}

import java.util.Scanner;
public class test{
    public static void main (String[] args){
        Scanner kbd = new Scanner (System.in);;
        int a = kbd.nextInt();
        taxes(a);
    }
	//Franxine
	public static int taxes(int n){
    		int i = 1;
    		int a = n % i;
    		while(a==0){
    			a = n % i;
    			i++;
    	}
    		i = i / 2;
    		return i;

    }
}

import java.util.Scanner;
public class Taxes{
	static int temp = 0;
	public static int computeMinPay(int n){
		if(isPrimeNumber(n) == false){
			if(n % 2 == 0 || isPrimeNumber(temp) == true) {
				return 2;
			}
			return 3;
		}
		return 1;
	}
	public static boolean isPrimeNumber(int n){
		if(n == 4)
			return false;
		for(int i = n/5; i >= 2; i--){
			if(n % i == 0) {
				temp = n/i;
				System.out.println("temp value: " + temp);
				return false;
			}
		}
		return true;
	}
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		System.out.print("");
		int n = scan.nextInt();
		System.out.print(computeMinPay(n));
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        if (isPrime(n)) out.println(1);
        else if (n % 2 == 0) out.println(2);
        else out.println(3);
        out.flush();
        out.close();
    }

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

    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        Scanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) throws IOException {
            int[] ans = new int[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextInt();
            return ans;
        }

    }

}

import java.util.*;
import java.io.*;
public class Main {
    static class Scan {
        private byte[] buf=new byte[1024];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }
        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n))
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
            if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
    static int primes[];
    public static void main(String args[]) throws IOException {
        Scan input=new Scan();
        int n=input.scanInt();
        primes=new int[9592];
        sieve(100001);
        int ans=0;
        for(int i=0;i<primes.length;i++) {
            while(n%primes[i]==0) {
                n/=primes[i];
                ans++;
            }
        }
        if(n!=1) {
            ans++;
        }
        System.out.println(ans);
    }
    //false for prime number and true for composite number
    public static void sieve(int n) {
        boolean sieve[]=new boolean[n];
        int indx=0;
        for(int i=2;i<n;i++) {
            if(!sieve[i]) {
                primes[indx]=i;
                indx++;
                for(int j=2*i;j<n;j=j+i) {
                    sieve[j]=true;
                }
            }
        }
//        System.out.println(indx);
    }
}

import java.util.*;
import java.math.*;

public class Main
{
	static final int MAX_PRIME = 100_001;
	static ArrayList<Integer> primes = new ArrayList<>();
	static BitSet sieve = new BitSet( MAX_PRIME );

	public static void main( String[] args )
	{
		Scanner is = new Scanner( System.in );
		sieve.set( 2, MAX_PRIME, true );
		for( long i = 2; i < MAX_PRIME; i++ )
			if( sieve.get( (int)i ) )
			{
				for( long j = i*i; j < MAX_PRIME; j += i )
					sieve.set( (int)j, false );
				primes.add( (int)i );
			}

		int n = is.nextInt();
		if( isPrime(n) )
			System.out.println( 1 );
		else {
			boolean twoNumber = false;
			for( int i = 0; primes.get(i) <= Math.sqrt(n); i++ )
				if( isPrime( n - primes.get(i) ) )
				{
					twoNumber = true;
					break;
				}
			System.out.println( twoNumber ? "2" : "3" );
		}
	}

	static boolean isPrime( int n )
	{
		if( n < MAX_PRIME )
			return sieve.get( n );
		int limit = (int)Math.sqrt( n );
		for( int i = 0; primes.get(i) <= limit; i++ )
			if( n % primes.get(i) == 0 )
				return false;
		return true;
	}
}

import java.util.Arrays;
import java.util.Scanner;

public class MainD {
    MyScanner sc    = new MyScanner();
    Scanner   sc2   = new Scanner(System.in);
    long      start = System.currentTimeMillis();
    long      fin   = System.currentTimeMillis();
    final int MOD   = 1000000007;
    int[]     dx    = { 1, 0, 0, -1 };
    int[]     dy    = { 0, 1, -1, 0 };

    void run() {
        int o = sc.nextInt();
        int n = o;
        int cnt = 0;
        while (o >= 2) {
            if (isPrime(n) && o - n != 1 && o-n != 4) {
                o -= n;
                n = o;
                cnt++;
            } else {
                n--;
            }
        }
        System.out.println(cnt);
    }

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

    public static void main(String[] args) {
        new MainD().run();
    }

    void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }

    void debug2(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }

    boolean inner(int h, int w, int limH, int limW) {
        return 0 <= h && h < limH && 0 <= w && w < limW;
    }

    void swap(int[] x, int a, int b) {
        int tmp = x[a];
        x[a] = x[b];
        x[b] = tmp;
    }

    // find minimum i (k <= a[i])
    int lower_bound(int a[], int k) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (k <= a[mid])
                r = mid;
            else
                l = mid;
        }
        // r = l + 1
        return r;
    }

    // find minimum i (k < a[i])
    int upper_bound(int a[], int k) {
        int l = -1;
        int r = a.length;
        while (r - l > 1) {
            int mid = (l + r) / 2;
            if (k < a[mid])
                r = mid;
            else
                l = mid;
        }
        // r = l + 1
        return r;
    }

    long gcd(long a, long b) {
        return a % b == 0 ? b : gcd(b, a % b);
    }

    long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    boolean palindrome(String s) {
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                return false;
            }
        }
        return true;
    }

    class MyScanner {
        int nextInt() {
            try {
                int c = System.in.read();
                while (c != '-' && (c < '0' || '9' < c))
                    c = System.in.read();
                if (c == '-')
                    return -nextInt();
                int res = 0;
                do {
                    res *= 10;
                    res += c - '0';
                    c = System.in.read();
                } while ('0' <= c && c <= '9');
                return res;
            } catch (Exception e) {
                return -1;
            }
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String next() {
            try {
                StringBuilder res = new StringBuilder("");
                int c = System.in.read();
                while (Character.isWhitespace(c))
                    c = System.in.read();
                do {
                    res.append((char) c);
                } while (!Character.isWhitespace(c = System.in.read()));
                return res.toString();
            } catch (Exception e) {
                return null;
            }
        }

        int[] nextIntArray(int n) {
            int[] in = new int[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextInt();
            }
            return in;
        }

        int[][] nextInt2dArray(int n, int m) {
            int[][] in = new int[n][m];
            for (int i = 0; i < n; i++) {
                in[i] = nextIntArray(m);
            }
            return in;
        }

        double[] nextDoubleArray(int n) {
            double[] in = new double[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextDouble();
            }
            return in;
        }

        long[] nextLongArray(int n) {
            long[] in = new long[n];
            for (int i = 0; i < n; i++) {
                in[i] = nextLong();
            }
            return in;
        }

        char[][] nextCharField(int n, int m) {
            char[][] in = new char[n][m];
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                for (int j = 0; j < m; j++) {
                    in[i][j] = s.charAt(j);
                }
            }
            return in;
        }
    }
}

import java.util.Scanner;

public class D {
	public static int MAX_PRIME = 50000;
    public static boolean[] primes = new boolean[MAX_PRIME];

	public static void main(String[] args) {
		findPrimes();
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		if (n%2 == 0 && n>2) {
			System.out.println(2);
			return;
		}
		if (isPrime(n)) {
			System.out.println(1);
			return;
		} else if (isPrime(n-2)) {
			System.out.println(2);
			return;
		} else {
			System.out.println(3);
			return;
		}
	}

	public static void findPrimes() {
        for (int i = 0; i < primes.length; i++) {
            primes[i] = true;
        }
        primes[0] = false;
        primes[1] = false;
        for (int i = 2; i < primes.length; i++) {
            for (int j = 2*i; j < primes.length; j+=i) {
                primes[j] = false;
            }
        }
    }

	private static boolean isPrime(long n) {
		if (n < 2) return false;
		if (n == 2) return true;
		if (n % 2 == 0) return false;
		if (n < MAX_PRIME) return primes[(int) n];
		for (int i = 2; i < Math.round(Math.sqrt(n)); i++) {
			if (!primes[i]) continue;
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}
}

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class TestClass {
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;

	public static class Queue{
		private class node{
			int val;
			node next;
			node(int a){
				val = a;
				next = null;
			}
		}
		node head,tail;
		Queue(){
			head = null;
			tail = null;
		}
		public void EnQueue(int a){
			if(head==null){
				node p = new node(a);
				head = p;
				tail = p;
			}
			else{
				node p = new node(a);
				tail.next = p;
				tail = p;
			}
		}
		public int DeQueue(){
			int a = head.val;
			head = head.next;
			return a;
		}
		public boolean isEmpty(){
			return head==null;
		}
	}
	public static long pow(long x,long y,long m){
		if(y==0)
    		return 1;
    	long k = pow(x,y/2,m);
    	if(y%2==0)
    		return (k*k)%m;
    	else
    		return (((k*k)%m)*x)%m;
    }
	static long Inversex = 0,Inversey = 0;
	public static void InverseModulo(long a,long m){
		if(m==0){
			Inversex = 1;
			Inversey = 0;
		}
		else{
    		InverseModulo(m,a%m);
    		long temp = Inversex;
    		Inversex = Inversey;
    		Inversey = temp+ - (a/m)*Inversey;
    	}
    }
    static long mod1 = 1000000007;
    static long mod2 = 1000000009;
	public static long gcd(long a,long b){
		if(a%b==0)
			return b;
		return gcd(b,a%b);
	}
	public static boolean isPrime(long a){
		if(a==1)
			return false;
		else if(a==2||a==3)
			return true;
		for(long i=2;i<=Math.sqrt(a);i++)
			if(a%i==0)
				return false;
		return true;
	}
	public static double distance(int a,int b,int x,int y){
		return Math.sqrt(((long)(a-x)*(long)(a-x))+((long)(b-y)*(long)(b-y)));
	}
	public static class Pair implements Comparable<Pair> {
		long u;
		long v;
		BigInteger bi;
		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}
		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}
		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}
		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
	public static int seive(int a[],boolean b[],TreeSet<Integer> c){
		int count = 0;
		for(int i=2;i*i<a.length;i++){
			if(!b[i]){
				for(int j=i*i;j<a.length;j=j+i)
					b[j] = true;
				c.add(i);
				a[count++] = i;
			}
		}
		return count;
	}
	public static void MatrixMultiplication(int a[][],int b[][],int c[][]){
		for(int i=0;i<a.length;i++){
			for(int j=0;j<b[0].length;j++){
				c[i][j] = 0;
				for(int k=0;k<b.length;k++)
					c[i][j]=(int)((c[i][j]+((a[i][k]*(long)b[k][j])%mod1))%mod1);
			}
		}
	}
	public static void Equal(int arr[][],int temp[][]){
		for(int i=0;i<arr.length;i++){
			for(int j=0;j<arr.length;j++)
				temp[i][j] = arr[i][j];
		}
	}
	static long max1 = (long) ((long) -1*10e15),index = -1,temp = -1;
	public static long dfs(ArrayList<Integer> a[],boolean u[],int arr[],int p,boolean v){
		if(p==temp)
			return (long) (-1*10e17);
		if(!v){
			u[p] = true;
			long count = (long) (-1*10e15);
			if((p!=0&&a[p].size()>2)||(p==0&&a[p].size()>1)){
				for(int i=0;i<a[p].size();i++)
					if(!u[a[p].get(i)])
						count = Math.max(count,dfs(a,u,arr,a[p].get(i),true));
			}
			else{
				for(int i=0;i<a[p].size();i++)
					if(!u[a[p].get(i)])
						count = Math.max(count,dfs(a,u,arr,a[p].get(i),false));
			}
			return count;
		}
		else{
			u[p] = true;
			long count = arr[p];
			for(int i=0;i<a[p].size();i++){
				if(!u[a[p].get(i)]){
					long ui = dfs(a,u,arr,a[p].get(i),true);
					count+=ui;
				}
			}
			if(max1<count){
				max1 = count;
				index = p;
			}
			return count;
		}
	}
	public static long co(int a[],TreeSet<Integer> t,int n,int p){
		if(t.contains(n))
			return 1;
		if(n>a[p-1]){
			long count = 1;
			int i;
			for(i=0;i<p;i++){
				if(n%a[i]==0){
					if(n-(n/a[i])==1)
						continue;
					count+=co(a,t,n-(n/a[i]),p);
					break;
				}
			}
			return count;
		}
		else{
			if(n-t.lower(n)!=1)
				return 1+co(a,t,n-t.lower(n),p);
			else
				return 1+co(a,t,n-t.lower(t.lower(n)),p);
		}
	}
	private static void soln(){
		int a[] = new int[(int) 10e5+10];
		boolean u[] = new boolean[(int) 10e5+10];
		TreeSet<Integer> t = new TreeSet<Integer>();
		int count = seive(a,u,t);
		int n = nI();
		pw.println(co(a,t,n,count));
	}
	public static void main(String[] args) {
		InputReader(System.in);
		pw = new PrintWriter(System.out);
		soln();
		pw.close();
	}
	// To Get Input
	// Some Buffer Methods
	public static void InputReader(InputStream stream1) {
		stream = stream1;
	}
	private static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
	private static boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}
	private static int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}
	private static int nI() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private static long nL() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	private static String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}
	private static String nLi() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}
	private static int[] nIA(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = nI();
		return arr;
	}
	private static long[] nLA(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
			arr[i] = nL();
		return arr;
	}
	private static void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++)
			pw.print(arr[i] + " ");
		pw.println();
		return;
	}
	private static void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++)
			pw.print(arr[i] + " ");
		pw.println();
		return;
	}
	private static boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}
	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

import java.util.*;
public class HelloWorld{

     public static void main(String []args){
        Scanner sc =new Scanner(System.in);
        long n =sc.nextLong();
        if(n==4){
            System.out.print("2");return;
        }
        if(n==3 || n==5 || n==2){
            System.out.print(1);return;
        }
        if((n&1)==1){
            System.out.print(3);
            return;
        }
        System.out.print(2);
     }
}