program cf736B;
var n:longint;
function prime(x:longint):boolean;
var i:longint;
begin
  for i:=2 to x-1 do
  begin
    if i*i>x then exit(true);
    if x mod i=0 then exit(false);
  end;
  exit(true);
end;
begin
  readln(n);
  if prime(n) then write(1)
    else if n mod 2=0 then write(2)
      else if prime(n-2) then write(2)
        else write(3);
end.

var
  n:longint;
function pd(k:longint):boolean;
var
  i:longint;
begin
  for i:=2 to trunc(sqrt(k)) do
  if k mod i=0 then exit(false);
  exit(true);
end;
begin
  read(n);
  if n<3 then writeln(1)
  else if not odd(n) then writeln(2)
  else
  begin
    if pd(n) then writeln(1)
    else if not pd(n-2)  then writeln(3)
    else writeln(2);
  end;
end.

var
  a,n,i:longint;
  t:boolean;
begin
  readln(n);
  if(n=1)or(n=2)then writeln(1)else
  if(n mod 2=0)then writeln(2)else
  begin
    a:=trunc(sqrt(n));
    for i:=2 to a do
      if(n mod i)=0then
      begin
        t:=true;
        break
      end;
    if not t then
    begin
      writeln('1');
      halt
    end;
    t:=false;
    dec(n,2);
    a:=trunc(sqrt(n));
    for i:=2 to a do
      if (n)mod i=0 then
      begin
        t:=true;
        break
      end;
    if t then
      writeln(3) else writeln(2);
  end
end.

var n:int64;
function p(x:int64):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
  if x mod i=0 then exit(false);
exit(true);
end;
begin
readln(n);
if p(n) then writeln(1)
else if n mod 2=0 then writeln(2)
else if p(n-2) then writeln(2)
else writeln(3);
end.

  program z1;
  var n,c:int64;
  i:longint;
  begin
    readln(n);
    case n of
      2:writeln(1);
      3:writeln(1);
      4:writeln(2);
      5:writeln(1);
      6:writeln(2);
      7:writeln(1);
      8:writeln(2);
      9:writeln(2);
    end;
    if n>=10 then begin
      for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then c:=1;
      if c=0 then begin
        writeln(1);
        exit;
      end;
      if n mod 2=0 then begin writeln(2);
      exit;
      end;
      n:=n-2;
      c:=0;
        for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then c:=1;
      if c=0 then begin
        writeln(2);
        exit;
      end;
      writeln(3);
      end;

  end.

program z1;
var a,b,c,d,i,j,k,l,m,n:longint;
begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n);
for i:=2 to round(sqrt(n)) do
 begin
 if n mod i=0 then a:=1;
 end;
if a=0 then begin write('1'); exit; end;
dec(n,2);
a:=0;
for i:=2 to round(sqrt(n)) do
 begin
 if n mod i=0 then a:=1;
 end;
n:=n+2;
if (n mod 2=0) or (a=0) then write('2') else write('3');
end.

var n:longint;
function pd(x:longint):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
  if x mod i=0 then
    exit(false);
exit(true);
end;
begin
//assign(input,'taxes.in');reset(input);
//assign(output,'taxes.out');rewrite(output);
readln(n);
if(n mod 2=0)and(n<>2)then writeln(2)
else
if pd(n)then writeln(1)
else
if pd(n-2)then writeln(2)
else
 writeln(3);
close(input);close(output);
end.

var n:int64;
function pd(x:int64):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
   if x mod i=0 then exit(false);
exit(true);
end;
begin
//assign(input,'taxes.in');reset(input);
//assign(output,'taxes.out');rewrite(output);
readln(n);
if pd(n) then writeln(1)
else if n mod 2=0 then writeln(2)
else if pd(n-2) then writeln(2)
else writeln(3);
close(input);close(output);
end.

var n:longint;
function pd(x:longint):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
  if x mod i=0 then exit(false);
exit(true);
end;
begin
//assign(input,'gdbhcx.in');reset(input);
//assign(output,'gdbhcx.out');rewrite(output);
readln(n);
if pd(n)then
  begin
  writeln(1);
  close(input);close(output);halt;
  end;
if(n mod 2=0)and(n>2)then writeln(2)
else begin
  if pd(n-2) then writeln(2)
  else writeln(3);
  end;
close(input);close(output);
end.

var n:longint;
function pd(x:longint):boolean;
var i:longint;
begin
if x<2 then exit(false);
for i:=2 to trunc(sqrt(x))do
  if x mod i=0 then exit(false);
exit(true);
end;
begin
//assign(input,'ss.in');reset(input);
//assign(output,'ss.out');rewrite(output);
readln(n);
if pd(n) then writeln(1) else
if(n mod 2=0)or(pd(n-2))then writeln(2) else writeln(3);
close(input);close(output);
end.

const
   fi = 'DDD.inp';
   fo = 'DDD.out';

var
   n:longint;

function check(x:longint):boolean;
var
   i:longint;
begin
   if x < 2 then exit(false);
   if x = 2 then exit(true);
   for i := 2 to trunc(sqrt(x)) do
      if x mod i = 0 then exit(false);

   exit(true);
end;

begin
   read(n);
   if check(n) then writeln(1) else
   if (n mod 2 = 0) and (n > 2) then writeln(2) else
   if (n mod 2 = 1) and (check(n-2)) then writeln(2) else writeln(3);
end.

var i,j,n,m,k,o,s:longint;
function aaa(x:longint):boolean;
var i:longint;
begin
  for i:=2 to trunc(sqrt(x)) do
  if x mod i=0 then exit(false);
  exit(true);
end;
begin
  readln(n);
  if aaa(n) then write(1)
  else if (aaa(n-2))or(n mod  2=0) then write(2)
  else write(3);
end.

const
  prime:array[1..14]of longint=(2,3,5,7,11,13,17,19,37,43,67,73,97,101);
var
  n:int64;
function cf(n,m,p:int64):int64;
var
  ans:int64;
begin
  ans:=0;
  while (m<>0) do
  begin
    if (m and 1<>0) then
      ans:=(ans+n) mod p;
    m:=m shr 1;
    n:=(n shl 1)mod p;
  end;
  exit(ans);
end;
function ksm(x,y,p:int64):int64;
var
  b:int64;
begin
  if y=1 then
    exit(x mod p);
  b:=ksm(x,y div 2,p);
  if odd(y) then
    exit(cf(b,b,p) mod p*x mod p) else
    exit(cf(b,b,p) mod p);
end;
function Miller_Rabin(n:int64):boolean;
var
  i,j,t:longint;
  u,now,res:int64;
begin
  Miller_Rabin:=true;
  for i:=1 to 5 do
  begin
    if n=prime[i] then
      exit(true);
    if n mod prime[i]=0 then
      exit(false);
  end;
  if n=1 then
    exit(false);
  u:=n-1;
  t:=0;
  while u mod 2=0 do
  begin
    u:=u >> 1;
    inc(t);
  end;
  for i:=1 to 5 do
  begin
    now:=ksm(prime[i],u,n);
    for j:=1 to t do
    begin
      res:=cf(now,now,n);
      if (res=1) and (now<>1) and (now<>n-1) then
        exit(false);
      now:=res;
    end;
    if now<>1 then
      exit(false);
  end;
end;
begin
  readln(n);
  if n=1 then
    writeln(1) else
  if Miller_Rabin(n) then
    writeln(1) else
  if not odd(n) then
    writeln(2) else
  if Miller_Rabin(n-2) then
    writeln(2) else
    writeln(3);
end.

Program ILoveYou;
VAR n:int64;

function Prim(x : int64) : boolean;
VAR i:int64;
Begin

Prim:=true;
i:=2;
while (i <= sqrt(x)) do
Begin
if ((x mod i) = 0) then Begin Prim:=false; i:=x; end;
i:=i + 1;
end;

end;

Begin

Readln(n);
if Prim(n) then Writeln(1) else
Begin

if ((n mod 2) = 0) then Writeln(2) else
Begin

if (Prim(n - 2)) then Writeln(2) else Writeln(3);

end;

end;

Readln;
END.

var n,i:longint;
    fl:boolean;
begin
 read(n);

 for i:=2 to round(sqrt(n)) do
  if n mod i = 0
   then begin fl:=true;break;end;
 if not fl
  then write(1)
  else begin
        if n mod 2 = 0
         then begin write(2);halt;end;
        n:=n-2;
        fl:=false;
        for i:=2 to round(sqrt(n)) do
         if n mod i = 0
          then begin fl:=true;break;end;
        if fl
         then write(3)
         else write(2);
       end;

end.

var d,x,ot,x2:int64;
function pr(x:int64):boolean;
var d:int64;
begin
if x mod 2 =0 then pr:=(x=2)
                else
                begin
  d:=3;
  while (d*d<=x)and(x mod d <>0) do
  d:=d+2;
  pr:=(d*d>x)and(x<>1);
end;
end;
begin
readln(x);

if pr(x) then writeln(1) else begin
if (x mod 2=1) and (x>5) and (pr(x-2)) then writeln(2) else
if (x mod 2=0) and (x>2) then writeln(2) else
if (x mod 2=1) and (x>5) then writeln(3) else
if (x=2) then writeln(1) else
if (x=3) then writeln(1) else
if (x=5) then writeln(1);
end;
End.

                    const eps=0.0000000001;  besk=20000000000008;  nn=200000;
   label 1,2,3,4;
    type
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;
   i1,j1,k1, step, i,j:longint;
    aanew,bbnew:extended;
     ss:string;
    s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;
    ddminus, ppole:array[-1..2000,-1000..1502] of int64;
   text,text1,text2:array[-10..2000000] of char;
     ss1,ss2:string;
     ddd,dd:array[-1..40000,-1..10] of int64;
     marked:array[-100000..500000] of boolean;
    sss:string;ch:char;
    pole :array [-10..500,-10..500] of char;
    st2:array[0..nn] of string;
     v0,v1,t0:real;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
       flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function koll(pp:longint):longint;
label 43;
 var ot,i,t:longint;
aanew:extended; flag:boolean;
begin
 flag:=true;
   aanew:=pp; aanew:=sqrt(aanew);
   t:=round(aanew+0.01);
  for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;
 { writeln(flag);
 }
  if flag then begin ot:=1; goto 43;  end;
  if odd(pp) then  begin ot:=3; goto 43;  end;
  if not odd(pp) then  begin ot:=2; goto 43;  end;
43:
 koll:=ot;
end;

function prost(pp:longint):boolean;
var i:longint;flag:boolean;
 begin
   flag:=true;
    for i:=2 to min(pp-1,100000) do
     if pp mod i=0 then flag:=false;

   prost:=flag;
 end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    {   for i:=2 to 30  do writeln(i,' ',koll(i));

     for i:=2000000002 to 2000000010  do writeln(i,' ',koll(i));
     }

   {  for i:=2 to 100 do if prost(i) then write(i,' ');
     writeln;
    }
    read(pp);
     if prost(pp-2) then tt:=2 else tt:=3;
    writeln(min(koll(pp),tt));

   1:    close(output);
end.

var
  a,b,i,n,k,j:longint;
  function f(n:longint):longint;
  var a,b,i:longint;
  begin
    a:=0;
    for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then a:=1;
    f:=a;
  end;
begin
  read(n);
  if f(n)=0 then writeln(1) else
  if (n mod 2=0) or (f(n-2)=0) then writeln(2) else
  writeln(3);
end.

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

function prost (a:longword):boolean;
var i:longint; flag:boolean;
begin
flag:=true;
 for i:=2 to trunc(sqrt(a)) do
  if a mod i = 0 then begin flag:=false; break; end;
 prost:=flag;
end;

var n,k,c,a,b:int64;
begin
 read(n);
 if prost(n) then writeln(1) else
  if n mod 2 = 0 then writeln(2) else
   if prost(n-2) then writeln(2) else
    writeln(3);
    readln;
    readln;
end.

program nalogi;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  w : boolean;
  n, i, res : integer;

begin
  readln ( n );

  w := true;
  i := 3;

  if ( n = 2 ) then
    w := true
  else
  if ( n mod 2 <> 0 ) then
   while ( i <= trunc ( sqrt ( n ) ) ) do begin
      if ( n mod i = 0 ) then begin
        w := false;
        break;
      end;
      inc ( i, 2 );
    end
  else
    w := false;

  if ( w ) then
    res := 1
  else
    if ( n mod 2 = 0 ) then
      res := 2
  else begin
    w := true;
    i := 3;
    dec ( n, 2 );
    while ( i <= trunc ( sqrt ( n ) ) ) do begin
      if ( n mod i = 0 ) then begin
        w := false;
        break;
      end;
      inc ( i, 2 );
    end;
    if ( w ) then
      res := 2
    else
      res := 3;
  end;

  writeln ( res );

  readln;
end.

program payment;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  n: integer;

function nal(n: integer): boolean;
var
  i: integer;
begin
  if ((n mod 2 = 0) and (n <> 2)) then begin
    result := false;
    exit;
  end;
  i := 3;
  while (i <= trunc(sqrt(n))) do begin
    if (n mod i = 0) then begin
      result := false;
      exit;
    end;
    inc(i, 2);
  end;
  result := true;
end;

begin
  readln(n);
  if (nal(n)) then
    writeln(1)
  else
  if ((nal(n - 2)) or (n mod 2 = 0)) then
    writeln(2)
  else
    writeln(3);
  readln;
  readln;
end.

var
 n:longint;
function ss(n:longint):boolean;
 var
  i:longint;
  p:boolean;
 begin
  p:=true;
  for i:=2 to trunc(sqrt(n)) do
   if n mod i=0 then begin p:=false;break;end;
  if n=1 then p:=false;
  exit(p);
 end;
begin
 read(n);
 if ss(n) then writeln(1)
 else if (n mod 2=0) or (ss(n-2)) then writeln(2)
 else writeln(3);
end.

var
        i,n:longint;
function zs(a:longint):longint;
var
        i:longint;
begin
        for i:=2 to trunc(sqrt(a)) do
        if a mod i=0 then exit(0);
        exit(1);
end;
begin
        read(n);
        if (zs(n)=1)then write(1)
        else
        if (n mod 2=0)then write(2)
        else
        if zs(n-2)=1 then write(2)
        else
        write(3);

end.

var a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')
  else if (n mod 2=0) then write('2')
    else begin
      k:=0;
      a:=trunc(sqrt(n));
      for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=0 then begin write('1'); exit; end;
      if k=1 then begin
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=1 then write('3') else write('2');
      end;
    end;
end.

var
 a,n,i,k:longint;
begin
  readln(n);
  if (n=1)or(n=2) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else
        begin
          for i:=2 to trunc(sqrt(n)) do
            if n mod i=0 then begin k:=1;break;end;
          if k=0 then begin writeln(1);exit;end;
          for i:=2 to trunc(sqrt(n-2)) do
            if (n-2) mod i=0 then begin writeln(3);exit;end;
          writeln(2);
        end;
end.

var n:longint;
function prost(x:int64):boolean;
var d:longint;
begin
if x mod 2 =0 then prost:=(x=2)
                else
                begin
  d:=3;
  while (d*d<=x)and(x mod d <>0) do
  d:=d+2;
  prost:=(x>1)and(d*d>x);

end;
end;
begin
  readln(n);
if prost (n) then writeln(1)
else
  if (n mod 2=1) and (n>5) and (prost(n-2)) then writeln(2)
  else
    if (n mod 2=0) and (n>2) then writeln(2)
    else
       if (n mod 2=1) and (n>5) then writeln(3)

    end.

var
p,n,i:longint;
bol:boolean;
begin
readln(n);
if n =2 then writeln(1)
else begin
if n mod 2 =  0 then writeln(2)
else begin
bol:=true;
    for i:=2 to round(sqrt(n)) do   if n mod i = 0 then bol:=false;
    if bol then writeln(1)
    else begin
    bol:=true;
    p:=n-2;
     for i:=2 to round(sqrt(p)) do   if p mod i = 0 then bol:=false;
     if bol then writeln(2)
     else
    writeln(3);

    end;
end;
end;
end.

var n : longint; { изначальная сумма }

{ определние простоты числа }
function isprime(n : longint) : Boolean;
var d : longint;
begin
isprime:=true;
d:=2;
	while d*d<=n do begin
	if n mod d=0 then begin isprime:=false; break; end;
  Inc(d);
  end;
end;

begin
readln(n);
if isprime(n) then writeln(1) { если простое, то налог - 1 }
else if (n mod 2 = 0) or (isprime(n-2)) { четное можно представить как два простых (гипотеза Гольдбаха) }
then writeln(2) { нечетное можно, если оно имеет вид 2+p, где p - простое, налог - 2 }
else writeln(3); { нечетные можно представить как n=n-3+3, n-3 четное, 3 простое, налог - 3 }
end.

var n:longint;
procedure check;
var f,i:longint;
begin
 f:=0;
 for i:=2 to round(sqrt(n)) do
  if n mod i=0 then begin f:=1; break; end;
 if f=0 then begin write(1); halt; end;
 if n mod 2=1 then begin
  f:=0;
  for i:=2 to round(sqrt(n-2)) do
   if (n-2) mod i=0 then begin f:=1; break; end;
  if f=0 then begin write(2); halt; end;
 end;
end;
begin
read(n);
check;
write(2+n mod 2);
end.

var
 n,m,i: longint;
 f: boolean;
begin
 readln(n);

 for i:=2 to trunc(sqrt(n)) do if n mod i = 0 then
 begin
  f:=true;
  break;
 end;

 if not f then begin writeln(1); halt; end;

 f:=false;
 if not odd(n) then writeln(2) else
 begin
  for i:=2 to trunc(sqrt(n-2)) do if (n-2) mod i = 0 then
  begin
   f:=true;
   break;
  end;

  if not f then writeln(2) else writeln(3);
 end;
end.

var  n:int64;
     res:longint;
procedure nhap;
   begin
     readln(n);
   end;
function kiemtra(x:int64):boolean;
   var i:longint;
   begin
      if x<4 then exit(true);
      for i:=2 to trunc(sqrt(x)) do
          if x mod i=0 then exit(false);
      exit(true);
   end;
procedure xuli;
  begin
    if kiemtra(n) then res:=1
       else if n mod 2=0 then res:=2
            else
               if kiemtra(n-2) then res:=2
               else res:=3;
  end;
procedure ghi;
   begin
     writeln(res);
   end;
BEGIN
  nhap;
  xuli;
  ghi;
END.

var n,i:int64;

function fun(n:longint):boolean;
  var i:longint;
  begin
    fun:=true;
    for i:=2 to trunc(sqrt(n)) do
      if n mod i = 0 then exit(false);
  end;

begin
  readln(n);
  if fun(n) then writeln(1)
    else if (n mod 2 = 0) or (fun(n-2)) then writeln(2)
      else writeln(3);

end.

var
n,i:longint;
bol:boolean;
begin
readln(N);
bol:=true;
for i:=2 to round(sqrt(n))  do begin
    if n mod i = 0 then begin
        bol:=false;
        break;
    end;
end;
if bol then writeln(1)
else begin
    if i mod 2 = 0 then writeln(2)
    else begin
         bol:=true;
        for i:=2 to round(sqrt((n-2))) do begin
            if ((n-2) mod i = 0)and(i<>n-2) then begin
               bol:=false;
               break;
            end;
        end;
        if bol then writeln(2)
        else
        writeln(3);
    end;
end;
end.

uses math;
const fi='';
      fo='';
var i,j,c,kq,n,m,nP:longint;
    a,p:array[1..1000000] of longint;
    f:array[1..1000000] of boolean;

procedure openf;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);
end;

procedure closef;
begin
  close(input); close(output);
end;

procedure sangNT(n:longint);
var i,j:longint;
begin
 f[1]:=false;
 nP:=0;
 for i:=2 to n do f[i]:=true;
 for i:=2 to n do
   if f[i] then
   begin
     inc(nP);
     p[nP]:=i;
     j:=2;
     while j<=n div i do
     begin
       f[i*j]:=false;
       inc(j);
     end;
   end;
end;

function nto(x:longint):boolean;
var i:longint;
begin
  if x<=1000000 then exit(f[x]);
  for i:=1 to nP do
  begin
    if p[i]>x div p[i] then break;
    if x mod p[i]=0 then exit(false);
  end;
  exit(true);
end;

procedure inkq;

begin
  sangNT(1000000);
  readln(n);
  if nto(n) then write(1)
  else if nto(n-2) or (n mod 2=0) then write(2)
  else write(3);

end;

BEGIN
  openf;
  inkq;
  closef;
END.

var n:longint;

function prime(x:longint):boolean;
var i:longint;
begin
     if x<2 then exit(false);
     for i:=2 to x do
     begin
          if i*i>x then break;
          if x mod i=0 then exit(false);
     end;
     exit(true);
end;

begin
     readln(n);
     if prime(n)=true then writeln(1)
     else if (n>2) and (n mod 2=0) or prime(n-2)=true then writeln(2)
     else writeln(3);
     //readln();
end.

{$Mode objfpc}

var
  n:int64;
  i:integer;

procedure check(o,x:int64);
var i:integer;
  begin
    for i:=2 to trunc(sqrt(o)) do
      if o mod i = 0 then exit;
    writeln(x);
    halt;
  end;

begin
  read(n);
  if n <= 3 then
    begin
      write(1); halt;
    end;
  if n mod 2 = 0 then
    begin
      write(2); halt;
    end;
  check(n,1);
  check(n-2,2);
  writeln(3);
end.

var i,j,m,n:longint;
    flag:boolean;
begin
    readln(n);
    flag:=true;
    for i:=2 to trunc(sqrt(n)) do if n mod i=0 then flag:=false;
    if flag then writeln(1) else if odd(n)=false then writeln(2) else begin
        m:=n-2;
        flag:=true;
        for i:=2 to trunc(sqrt(m)) do if m mod i=0 then flag:=false;
        if flag then writeln(2) else writeln(3);
    end;

end.

Program taxes;
Var n,i:int64;
Begin
Readln(n);
i:=2;
If n=2 then writeln(1) else begin
If n mod 2=0 then writeln(2) else begin
While (n mod i<>0) and (i<sqrt(n)) do
Inc(i);
If i>sqrt(n) then writeln(1) else begin
i:=2;
While ((n-2) mod i<>0) and (i<sqrt(n-2)) do
Inc(i);
If i>sqrt(n-2) then writeln(2) else writeln(3);
end;
end;
end;
end.

 var n,i:longint;
     b:boolean;
begin
 readln(n);
 b:=true;
 for i:=2 to round(sqrt(n)) do
   if n mod i = 0 then begin
     b:=false;
     break;
   end;
 if b then
   writeln(1);
 if not b then
   if n mod 2 = 0 then
     writeln(2)
   else begin
     dec(n,2);
     b:=true;
 for i:=2 to round(sqrt(n)) do
   if n mod i = 0 then begin
     b:=false;
     break;
   end;
     if not b then
     writeln(3)
     else
       writeln(2);
   end;
end.

{$MODE OBJFPC}
var
        n : integer;
function prime (x : integer) : boolean;
var
        i : integer;
begin
        if x < 2 then exit(false);
        if x = 2 then exit(true);
        for i:=2 to trunc(sqrt(x)) do
                if x mod i = 0 then exit(false);
        exit(true);
end;
BEGIN
        readln(n);
        if prime(n) then write(1)
        else
                if (n mod 2 = 0) and (n >= 2) then write(2)
                        else if prime(n - 2) then write(2) else write(3);
END.

const   fi='';//735D.inp';
        fo='';//735D.out';

var     n : longint;

function nto(x: longint): boolean;
var     i: longint;
begin
        if x<2 then exit(false);
        for i:=2 to trunc(sqrt(x)) do
        if x mod i=0 then exit(false);
        exit(true);
end;

procedure doc;
begin
     //   assign(input,fi); reset(input);
    //    assign(output,fo); rewrite(output);
        read(n);

        if nto(n) then write(1) else
        if (n mod 2=0) or (nto(n-2)) then write(2) else
        write(3);

end;

begin
doc;
end.

CONST FI='';
      FO='';
var m,n,i,j,k:longint;
procedure doc;
begin
     assign(input,fi);
     reset(input);
     read(n);
end;
function kt(x:longint):boolean;
var i:longint;
begin
     if x<2 then exit(false);
     if x=2 then exit(true);
     for i:=2 to trunc(sqrt(x)) do
     if x mod i=0 then exit(false);
     exit(true);
end;
procedure xuli;
begin
      if kt(n) then
      begin
            write(1);
            exit;
      end;

      if ( n mod 2=0) or kt(n-2) then
      begin
            write(2);
            exit;
      end
      else
      write(3);
end;
procedure inkq;
begin
      assign(output,fo);
      rewrite(output);
      xuli;
end;
begin
doc;
inkq;
end.

Const Finp='';
      Fout='';
Var n:longint;

Procedure Nhap;
Var f:Text;
    i:longint;
Begin
    assign(f,finp); reset(f);
    read(f,n);
    close(f);
End;
Function Solve:longint;
Var i:longint;
    lc:boolean;
Begin
    if n=0 then exit(0);
    lc:=false;
    for i:=2 to trunc(sqrt(n)) do
        if n mod i=0 then
            begin
                lc:=true;
                break;
            end;
    if lc=false then exit(1);
    if n mod 2=0 then exit(2);
    lc:=false;
    for i:=2 to trunc(sqrt(n-2)) do
        if (n-2) mod i=0 then
            begin
                lc:=true;
                break;
            end;
    if (n>2) and (lc=false) then exit(2);
    exit(3);
End;
Procedure Xuat_Solve;
Var f:Text;
    res:longint;
Begin
    assign(f,fout); rewrite(f);
    res:=solve;
    write(f,res);
    close(f);
End;

Begin
    Nhap;
    Xuat_Solve;
End.

var n,i:longint;
function kt(x:longint):boolean;
 var i:longint;
  begin
   if x = 2 then exit(true);
   if x < 2 then exit(false);
   for i:=2 to trunc(sqrt(x)) do
    if x mod i = 0 then exit(false);
   exit(true);
  end;
begin
 readln(n);
 if kt(n) then begin write(1); exit; end;
 if n mod 2 = 0 then begin write(2); exit; end;
 n:=n-2;
 if kt(n) then write(2)
  else
   write(3);
end.

var
 n:longint;
function sushu(j:longint):boolean;
var
 k:longint;
begin
 if j<2 then exit(false);
 for k:=2 to trunc(sqrt(j)) do
  if j mod k=0 then exit(false);
 exit(true);
end;
begin
 read(n);
 if sushu(n) then writeln(1)
 else if(n mod 2=0)or(sushu(n-2))then writeln(2)
 else writeln(3);
end.

uses math;
const    fi = '735d.inp';
         fo = '735d.out';
         maxn = 1000005;
var
   n,t,sl:longint;
   d,a,f:array[1..maxn]of longint;

procedure enter;
var   i:longint;
begin
   readln(n);
end;
procedure sangnt;
var i,j:longint;
begin
   for i:=2 to trunc(sqrt(maxn)) do
   if d[i]=0 then
   begin
      j:=i*i;
      while(j<=maxn)do
      begin
         d[j]:=1; inc(j,i);
      end;
   end;
end;

function check(x:longint):boolean;
var j:longint;
begin
   if x<=maxn then  exit(d[x]=0);
   for j:=2 to trunc(sqrt(x)) do
   if x mod j=0 then exit(false);
   exit(true);
end;
function tinh(x:longint):longint;
var i:longint;
begin
   if x=0 then exit(0);
   if f[x]<>-1 then exit(f[x]);
   f[x]:=maxn;
   for i:=sl downto 1 do
   if x-a[i]>=0 then
   f[x]:=min(f[x],tinh(x-a[i])+1);
   exit(f[x]);
end;
procedure solve;
var   i,j,dem,res:longint;
begin
   t:=0;dem:=0;  fillchar(f,sizeof(f),255);
   j:=2; sl:=0;  res:=maxlongint;
   repeat
      if n-t<=1 then break;
      if (t<>1)and(check(n-t)) then
      begin inc(dem);
      while(j<=t)do
      begin
         if d[j]=0 then begin inc(sl); a[sl]:=j; end;
         inc(j);
      end;
      res:=min(res,tinh(t)+1);
      end;
      if dem=100 then break;
      inc(t);
   until 1=2;
   writeln(res);

end;

BEGIN
 //  assign(input,fi); reset(input);
 //  assign(output,fo); rewrite(output);
   enter;
     sangnt;
   solve;
   close(input); close(output);
END.

var
  n,i,j:longint;
  p:boolean;
begin
  read(n);
  if n<=2 then begin write(1); halt; end;
  if n mod 2=0 then begin write(2); halt; end;
  p:=true;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then begin write(1); halt; end;
  p:=true;
  n:=n-2;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then write(2) else write(3);
end.

var a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')
  else if (n mod 2=0) then write('2')
    else begin
      k:=0;
      a:=trunc(sqrt(n));
      for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=0 then begin write('1'); exit; end;
      if k=1 then begin
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=2 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=1 then write('3') else write('2');
      end
    end
end.

Var
    n   :   longint ;

Function CheckPrime(n   :   longint)    :   boolean ;
    Var i   :   longint ;
    Begin

        if (n = 2) or (n = 3) then exit(true) ;

        for i := 2 to trunc(sqrt(n)) do
            if (n mod i = 0) then exit(false) ;

        exit(true) ;

    End;

Procedure Enter ;
    Var i,j :   longint ;
    Begin

        read(n) ;
        if (checkPrime(n)) then writeln(1)
        else

            Begin

                if (n mod 2 = 0) then writeln(2)
                else

                    begin

                        if (checkPrime(n-2)) then writeln(2) else writeln(3) ;

                    end ;

            end ;

    End ;

Begin

    //Assign(input,'735D.inp') ; reset(input) ;

    Enter ;

    //Close(input) ;

End.

var now:longint;
function flag(x:longint):boolean;
var i:longint;
begin
  for i:=2 to trunc(sqrt(x)) do
	if (x mod i=0) then exit(false);
  exit(true);
end;
begin
  readln(now);
  if (flag(now)) then writeln('1')
  else if (now mod 2=1) then
  begin
    if (flag(now-2)) then writeln('2') else writeln('3');
  end
  else writeln('2');
end.

program chmn;
var
  n:longint;

function simple(n:longint):longint;
var
  i:longint;
begin

  for i:=2 to trunc(sqrt(n)) do
   if n mod i=0 then exit(1);

  exit(0);

end;

begin
  {Assign(input,'input.txt');
  Reset(input);
  Assign(output,'output.txt');
  Rewrite(output);}

  readln(n);

  if simple(n)=0 then writeln(1)
  else if n mod 2=0 then writeln(2)
  else if simple(n-2)=0 then writeln(2)
  else writeln(3);

//Close(input); Close(output);
end.

var n:int64;

procedure check(o,x:int64);
var i:longint;
begin
  for i:=2 to trunc(sqrt(o)) do if o mod i = 0 then exit;
  writeln(x);
  halt;
end;

begin
  readln(n);
  if n<=3 then begin write(1); halt;end;
  if not odd(n) then begin write(2); halt;end;
  check(n,1);
  check(n-2,2);
  writeln(3);
end.

uses    math;

var     f:array[1..1000000] of boolean;
        p:array[1..1000000] of longint;
        n,nP:longint;

procedure mofile;
begin
        assign(input,'codeforces.inp');
        assign(output,'codeforces.out');
        reset(input);
        rewrite(output);
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

procedure doc;
begin
        read(n);
end;

procedure sangNT(n:longint);
var     i,j:longint;
begin
        for i:=1 to n do f[i]:=true;
        f[1]:=false;
        for i:=2 to n do
            if f[i] then
            begin
                inc(nP);
                p[nP]:=i;
                for j:=2 to n div i do f[i*j]:=false;
            end;
end;

function NT(n:longint):boolean;
var     i:longint;
begin
        if n<=1000000 then exit(f[n]);
        for i:=1 to nP do
        begin
            if p[i]>trunc(sqrt(n)) then break;
            if n mod p[i]=0 then exit(false);
        end;
        exit(true);
end;

procedure xuly;
var     i,d:longint;
begin
        sangNT(1000000);
        if NT(n) then write(1)
        else
        if n mod 2=0 then write(2)
        else
        if NT(n-2) then write(2)
        else
        write(3);
end;

BEGIN

        doc;
        xuly;

END.

var n:longint;
function jj(n:longint):boolean;
var i:longint;k:boolean;
begin
K:=true;
 i:=3; while i*i<=n do
 begin
   if n mod i=0 then begin k:=false;break;end;
   inc(i,2);
 end;
 jj:=k;
end;
begin
 read(n);
 if n<4 then write (1) else if n mod 2= 0 then write(2) else
 if n<9 then write(1) else
 begin
   if jj(n) then write(1) else if jj(n-2) then write(2) else write(3);
 end;
end.

var
        n,res : longint;

function isprime(x : longint) : boolean;
        var
                i : longint;
        begin
                for i := 2 to trunc(sqrt(x)) do
                        if x mod i = 0 then exit(false);
                exit(true);
        end;

procedure main;
        var
                ok : boolean;
        begin
                read(n);
                if (n = 2) or (n = 3) or (n = 5) then res := 1
                else
                        if n mod 2 = 0 then res := 2
                                else
                                        begin
                                                if isprime(n) then res := 1
                                                        else if isprime(n-2) then res := 2
                                                                else res := 3;
                                        end;
                writeln(res);

        end;

begin
        main;
end.

var
  a, b, c, d: int64;

function test(a: int64): boolean;
var
  i: int64;

begin
  i := 2;
  while i * i <= a do begin
    if a mod i = 0 then begin
      test := false;
      exit;
    end;
    inc(i);
  end;
  test := true;
end;

begin
  readln(a);
  if test(a) then begin
    writeln(1);
    halt();
  end;
  if a mod 2 = 0 then begin
    writeln(2);
    halt();
  end;
  if test(a - 2) then begin
    writeln(2);
    halt();
  end;
  writeln(3);
end.

var n:longint;
  function check(k:longint):boolean;
  var i:longint;
  begin
    for i:=2 to trunc(sqrt(k)) do
      if k mod i=0 then exit(false);
    exit(true);
  end;
begin
  readln(n);
  if check(n) then writeln(1)
  else if (n mod 2=0)or(check(n-2)) then writeln(2)
  else writeln(3);
end.

var
 a,b,c,i,j:longint;
function proverka(a:Longint):longint;
var sqx,b,sc,i:Longint;
begin
 proverka:=0;
 sqx:=trunc(sqrt(a));
 for i:=2 to sqx do if a mod i=0 then begin proverka:=1; exit; end;
end;
begin
 readln(a);
 if proverka(a)=0 then begin writeln(1); halt; end;
 if a mod 2=0 then begin writeln(2); halt; end;
 if proverka(a-2)=0 then begin writeln(2); halt; end;
 writeln(3);
end.

var n: longword;
procedure doc;
  begin
    read(n);
  end;
function nto (x: longword): boolean;
  var i: longword;
  begin
    for i:=2 to round(sqrt(x)) do
      if (x mod i)=0 then exit(false);
    exit(true);
  end;
function xli: byte;
  begin
    if nto(n) then exit(1)
    else if not odd(n) then exit(2)
         else if nto(n-2) then exit(2)
              else exit(3);
  end;
procedure ghi;
  begin
    write(xli);
  end;
begin
  doc;
  ghi;
end.

program yan;
  var x,y,n,m:longint;
  function prov(x:longint):boolean;
    var i,j,a:longint;
    begin
      prov:=true;
      for i:=2 to round(sqrt(x)) do
        if x mod i=0 then
          begin
            prov:=false;
            break;
          end;
    end;
begin
  readln(n);
  if n<=3 then
    begin
      write(1); exit;
    end;
  if not odd(n) then
    begin
      write(2); exit;
    end;
  if prov(n) then
    begin
      write(1); exit;
    end;
  if prov(n-2) then
    begin
      write(2); exit;
    end;
  write(3);
end.

var
 n:longint;
function ss(n:longint):boolean;
var
 i:longint;
begin
 if n<2 then exit(false);
 for i:=2 to trunc(sqrt(n)) do
  if n mod i=0 then exit(false);
 exit(true);
end;
begin
 readln(n);
 if ss(n) then writeln(1)
  else if n mod 2=0 then writeln(2)
   else if ss(n-2) then writeln(2)
    else writeln(3);
end.

var
	n:longint;
function prime(x:longint):boolean;
var
	j,t:longint;
begin
	if x=1 then exit(false);
	t:=trunc(sqrt(x));
	for j:=2 to t do
		if x mod j=0 then exit(false);
	exit(true);
end;
begin
	readln(n);
	if (n=1) or (n=2) then
	begin
		writeln(1);
		halt;
	end;
	if n mod 2=0 then
	begin
		writeln(2);
		halt;
	end;
	if n mod 2=1 then
		if prime(n) then writeln(1)
		else if prime(n-2) then writeln(2)
			else writeln(3);
end.

var
 a,n,i,k:longint;
begin
  readln(n);
  if (n=1)or(n=2) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else
        begin
          for i:=2 to trunc(sqrt(n)) do
            if n mod i=0 then begin k:=1;break;end;
          if k=0 then begin writeln(1);exit;end;
          for i:=2 to trunc(sqrt(n-2)) do
            if (n-2) mod i=0 then begin writeln(3);exit;end;
          writeln(2);
        end;
end.

var
 n:longint;
function x(n:longint):boolean;
 var
 i:longint;
 p:boolean;
 begin
p:=true;
for i:=2 to trunc(sqrt(n)) do
 if n mod i=0 then begin p:=false;break;end;
if n=1 then p:=false;
exit(p);
end;
begin
read(n);
if x(n) then writeln(1)
else if (n mod 2=0) or (x(n-2)) then writeln(2)
else writeln(3);
end.

const
        fi = '';//735d.inp'  ;
        fo = '';//735d.out'  ;

var
        n : longint;

function  isprime(nn : longint) : boolean;
var  i : longint;
begin
        if n < 2 then exit(false);
        if n < 4 then exit(true);
        for i := 2 to round(sqrt(nn))+1 do
        if nn mod i = 0 then exit(false);
        exit(true);
end;

procedure  doc;
begin
        assign(input, fi); reset(input);
        assign(output, fo); rewrite(output);
        read(n);
        if isprime(n) then
        begin
                writeln(1);
                exit;
        end;
        if (n mod 2 = 0) or isprime(n-2) then
        begin
                write(2);
                exit;
        end;
        writeln(3);
end;

begin
        doc;
end.

{$R-,Q-,S-,I-}
{$OPTIMIZATION LEVEL2}
{$INLINE ON}

uses math;

procedure mofile;
begin
        {$IFDEF ONLINE_JUDGE}
        assign(input,'');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ELSE}
        assign(input,'checking.inp');
        reset(input);
        assign(output,'');
        rewrite(output);
        {$ENDIF}
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

const
        maxc=1000000000+69;
        modulo=1000000000+7;
        maxn=trunc(sqrt(maxc))+10;

type
        re=record
                x,y:longint;
        end;

var
        n:longint;
        kt:array[0..maxn] of longint;

function nt(n:longint):boolean;
var
        i:longint;
begin
        if n<2 then exit(false);
        for i:=2 to trunc(sqrt(n)) do
        if n mod i=0 then exit(false);
        exit(true);
end;

function cal(n:longint):longint;
var
        m,i,j:longint;
begin
        if n=0 then exit(0);
        if nt(n) then exit(1);
        if n mod 2=0 then exit(2);
        if (n>2) and nt(n-2) then exit(2);
        exit(3);
end;

procedure xuli;
var
        p:longint;
begin
        readln(n);
        writeln(cal(n));
end;

begin
        //mofile;
        xuli;
        dongfile;
end.

var
        n,i:longint;
        bz:boolean;
begin
        readln(n);
        bz:=false;
        for i:=2 to trunc(sqrt(n)) do
                if n mod i=0 then
                begin
                        bz:=true;
                        break;
                end;
        if bz=false then
        begin
                writeln(1);
                halt;
        end;
        if n mod 2=0 then
        begin
                writeln(2);
                halt;
        end;
        bz:=false;
        for i:=2 to trunc(sqrt(n-2)) do
                if (n-2) mod i=0 then
                begin
                        bz:=true;
                        break;
                end;
        if bz=false then writeln(2)
        else writeln(3);
end.

var n:longint;
function tfboys(n:longint):boolean;
var i:longint;
begin
  if n<2 then exit(false);
  for i:=2 to trunc(sqrt(n))  do
    if n mod i=0 then exit(false);
  exit(true);
end;

begin
  readln(n);
  if tfboys(n) then writeln(1)
  else if (n mod 2=0) or (tfboys(n-2)) then writeln(2)
  else writeln(3);
end.

var n,i,k,k1:longint;
begin
read(n);
for i:=2 to round(sqrt(n)) do
if n mod i=0 then begin k:=1; break; end;

if k=1 then if n mod 2=0 then write(2)
else begin
n:=n-2;
for i:=2 to round(sqrt(n)) do
if n mod i=0 then begin k1:=1; break; end;
if k1=0 then write(2) else write(3) end
else write(1);
end.

const fi='';
      fo='';
var n:longint;
function prime(x:longint):boolean;
var i:longint;
begin
        for i:=2 to trunc(sqrt(x)) do
                if x mod i=0 then
                        exit(false);
        exit(true);
end;
begin
        assign(input,fi); reset(input);
        assign(output,fo); rewrite(output);
        readln(n);
        if not prime(n) then
                if n mod 2=0 then write(2)
                else if prime(n-2) then write(2)
                else write(3)
        else write(1);
        close(input);
        close(output);
end.

const INP='';
OUTP='';
var f:text;
n:longint;
procedure nhap;
begin
assign(f,INP);
reset(f);
readln(f,n);
close(f);
end;
function get(x:longint):boolean;
var i,j:longint;
begin
for i:=2 to trunc(sqrt(n)) do
if x mod i = 0 then exit(false);
get:=true;
end;
procedure xuLi;
begin
assign(f,OUTP);
rewrite(f);
if get(n) then
write(f,1) else
if (n mod 2=0) or get(n-2) then write(f,2)
else write(f,3);
close(f);
end;
begin
nhap;
xuLi;
end.

var n:longint;

function prime(x:longint):boolean;
var i:longint;
begin
     if x<2 then exit(false);
     for i:=2 to x do
     begin
          if i*i>x then break;
          if x mod i=0 then exit(false);
     end;
     exit(true);
end;

begin
     readln(n);
     if prime(n)=true then writeln(1)
     else if (n>2) and (n mod 2=0) or prime(n-2)=true then writeln(2)
     else writeln(3);
     //readln();
end.

var
  n:int64;
 function pd(n:int64):boolean;
  var
    i:longint;
  begin
    if n<=1 then exit(false);
    for i:=2 to trunc(sqrt(n)) do if n mod i=0 then exit(false);
    exit(true);
  end;
begin
  readln(n);
  if pd(n) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else if pd(n-2) then writeln(2)
        else writeln(3);
end.

var
 n,i,k:longint;
begin
 read(n);
 if (n=1) or (n=2) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else
        begin
          for i:=2 to trunc(sqrt(n)) do if n mod i=0 then begin k:=1;break;end;
          if k=0 then begin writeln(1);halt;end;
          for i:=2 to trunc(sqrt(n-2)) do if (n-2) mod i=0 then begin writeln(3);halt;end;
          writeln(2);
        end;
end.

var
  n,k,ans : longint;

  function pr(x : longint) : boolean;
    var
      i : longint;
    begin
      if x = 1 then exit(false);
      if x = 2 then exit(true);
      for i:=2 to trunc(sqrt(x))+1 do
        if x mod i = 0 then exit(false);
      exit(true);
    end;

begin
  readln(n);
  if pr(n) then ans:=1 else begin
    if n mod 2 = 0 then ans:=2 else begin
    if pr(n-2) then ans:=2 else ans:=3; end;
  end;
  writeln(ans);
end.

var n,i:longint;
    fl:boolean;
begin
 read(n);

 for i:=2 to round(sqrt(n)) do
  if n mod i = 0
   then begin fl:=true;break;end;
 if not fl
  then write(1)
  else if n mod 2 =1
        then write(3)
        else write(2);

end.

var
  a,b,i,n,k,j:longint;
  function f(n:longint):longint;
  var a,b,i:longint;
  begin
    a:=0;
    for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then a:=1;
    f:=a;
  end;
begin
  read(n);
  if f(n)=0 then writeln(1) else
  if (n mod 2=0) and (f(n-2)=0) then writeln(2) else
  writeln(3);
end.

var n, k : longint;

function Simp (n : longint) : longint;
var i : longint;
check : boolean;

begin
while n>0 do begin
check:=true;
i:=2;
while i*i<=n do
begin
  if n mod i = 0
  then begin check:=false; break; end;
  Inc(i);
end;
if check then begin Simp:=n; break; end;
n:=n-1;
end;
end;

begin
k:=0;
readln(n);
while n>0 do begin
Inc(k);
n:=n-Simp(n);
end;
writeln(k);
end.

var
 a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')
                  else if (n mod 2=0) then write('2')
    else
     begin
      k:=0;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=0 then begin write('1'); exit; end;
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=1 then write('3') else write('2');
     end;
end.

var
 a,n,i,k:longint;
begin
  readln(n);
  if (n=1)or(n=2) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else
        begin
          a:=trunc(sqrt(n));
          for i:=1 to a do
            if n mod i=0 then begin k:=1;break;end;
          if k=0 then begin writeln(1);exit;end;
          a:=trunc(sqrt(n-2));
          for i:=1 to a do
            if n mod i=0 then begin writeln(3);exit;end;
          writeln(2);
        end;
end.

var a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')//特判
  else if (n mod 2=0) then write('2')//当n为偶数时付2单位税
    else begin
      k:=0;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;//判断是否质数
      if k=0 then begin write('1'); exit; end;//当n为质数时付1单位税
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;//判断是否质数
      if k=1 then write('3') else write('2');//当n-2为质数时付2单位税，否则付3单位税；
    end;
end.

var n,i:int64;

function fun(n,q:int64):int64;
  var i:longint; k:int64;
  begin
    k:=1;
    while k=1 do
      begin
        k:=0;
        for i:=round(sqrt(n)) downto 2 do
          if n mod i = 0 then begin dec(n); k:=1; break; end;
        if q-n=1 then begin dec(n); k:=1; end;
        if (k=0) then exit(n);
      end;
  end;

begin
  readln(n);
  i:=0;

  while n > 0 do
    begin   //writeln(fun(n,n));
      n:=n-fun(n,n);
      inc(i);
    end;

  writeln(i);

end.

var i,j,m,n:longint;
    flag:boolean;
begin
    readln(n);
    flag:=true;
    for i:=2 to trunc(sqrt(n)) do if n mod i=0 then flag:=false;
    if flag then writeln(1) else if odd(n)=false then writeln(2) else writeln(3);

end.

program yan;
  var i,j,x,y,a,b,n,m:longint;
  function prov(a:longint):boolean;
    var i,j,x,y:longint;
    begin
      prov:=false;
      for i:=2 to round(sqrt(a)) do
        if a mod i=0 then
          begin
            prov:=true;
            break;
          end;
    end;
begin
  readln(n);
  //for n:=30 to 100 do
  //begin m:=0;
  if not prov(n) then begin writeln(1); exit; end;
  a:=n-2; b:=2;
  while a>0 do
    begin
      if (not(not prov(a))and(not prov(b)))and(b<=round(sqrt(a))) then begin dec(a); inc(b); end
      else
      begin
        inc(m);
        if not prov(b) then break;
        a:=b-2; b:=2;
      end;
    end;
  if prov(n) then writeln(m+1);//end;
end.

// luogu-judger-enable-o2
var i:longint;n:int64;
f:boolean;
begin
readln(n);
if (n=1)or(n=2) then begin writeln('1');exit;end;
if (n mod 2=0) then begin writeln('2');exit;end;
for i:=1 to trunc(sqrt(n)) do
  if (n mod i)=0 then
    begin
    f:=true;
    break;
    end;
if not(f) then begin write('1');exit;end;
f:=false;
dec(n,2);
for i:=1 to trunc(sqrt(n)) do
  if (n mod i)=0 then
    begin
    f:=true;
    break;
    end;
if f then writeln('3')
     else writeln('2');
end.

var
  a,n,i:longint;
  t:boolean;
begin
  readln(n);
  if(n=1)or(n=2)then writeln(1)else
  if(n mod 2=0)then writeln(2)else
  begin
    t:=false;
    a:=trunc(sqrt(n));
    for i:=1 to a do
      if(n mod i)=0then
      begin
        t:=true;
        break
      end;
    if not t then
    begin
      writeln('1');
      halt
    end;
    t:=false;
    a:=trunc(sqrt(n-2));
    for i:=1 to a do
      if (n-2)mod i=0 then
      begin
        t:=true;
        break
      end;
    if t then
      writeln(3) else writeln(2);
  end
end.

var
  n,k,ans : longint;

  function pr(x : longint) : boolean;
    var
      i : longint;
    begin
      if x = 1 then exit(false);
      if x = 2 then exit(true);
      for i:=2 to trunc(sqrt(x))+1 do
        if x mod i = 0 then exit(false);
      exit(true);
    end;

begin
  readln(n);
  if pr(n) then ans:=1 else begin
    if n mod 2 = 0 then ans:=2 else ans:=3;
  end;
  writeln(ans);
end.

var
  i,j,n,m,k:longint;
begin
read(n);
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=1 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;exit;end;
  if k=0 then write(2) else write(3);
  end;
  end.

 var n,i:longint;
begin
 readln(n);
 for i:=2 to round(sqrt(n)+1) do
   if n mod i = 0 then break
   else
     if i=round(sqrt(n)+1) then
       writeln(1);
 if i<round(sqrt(n)+1) then
   if n mod 2 = 0 then
     writeln(2)
   else
     writeln(3);
end.

const fi='';
      fo='';
var n:longint;
function prime(x:longint):boolean;
var i:longint;
begin
        for i:=2 to trunc(sqrt(x)) do
                if x mod i=0 then
                        exit(false);
        exit(true);
end;
begin
        assign(input,fi); reset(input);
        assign(output,fo); rewrite(output);
        readln(n);
        if not prime(n) then
                if n mod 2=0 then write(2)
                else write(3)
        else write(1);
        close(input);
        close(output);
end.

var a,n,i:longint;
    b:boolean;
begin
  read(n);
  if n<=2 then writeln(1)
  else if not(odd(n)) then write(2)
  else begin
      for i:=1 to trunc(sqrt(n-2)) do
       if (n mod i)=0 then begin b:=true;break; end;
      if b then begin write(1); exit; end;
      b:=false;
      for i:=1 to trunc(sqrt(n-2)) do if ((n-2) mod i)=0 then begin b:=true; break; end;
      if b then write(3) else write(2);
  end;
end.

uses math;
const fi='';
      fo='';
var i,j,c,kq,n,m,nP:longint;
    a,p:array[1..1000000] of longint;
    f:array[1..1000000] of boolean;

procedure openf;
begin
  assign(input,fi); reset(input);
  assign(output,fo); rewrite(output);
end;

procedure closef;
begin
  close(input); close(output);
end;

procedure sangNT(n:longint);
var i,j:longint;
begin
 f[1]:=false;
 nP:=0;
 for i:=2 to n do f[i]:=true;
 for i:=2 to n do
   if f[i] then
   begin
     inc(nP);
     p[nP]:=i;
     j:=2;
     while j<=n div i do
     begin
       f[i*j]:=false;
       inc(j);
     end;
   end;
end;

function nto(x:longint):boolean;
var i:longint;
begin
  if x<=1000000 then exit(f[x]);
  for i:=1 to nP do
  begin
    if p[i]>x div p[i] then break;
    if x mod p[i]=0 then exit(false);
  end;
  exit(true);
end;

procedure inkq;

begin
  sangNT(1000000);
  readln(n);    kq:=0;
  while not nto(n) do
  begin
       m:=n-2;
       while not nto(m) do dec(m);
       inc(kq);
       n:=n-m;
  end;
  if n=0 then writeln(kq) else writeln(kq+1);
end;

BEGIN
  openf;
  inkq;
  closef;
END.

const
   fi = 'DDD.inp';
   fo = 'DDD.out';

var
   n:longint;

function check(x:longint):boolean;
var
   i:longint;
begin
   if x < 2 then exit(false);
   if x = 2 then exit(true);
   for i := 2 to trunc(sqrt(x)) do
      if x mod i = 0 then exit(false);

   exit(true);
end;

begin
   read(n);
   if n = 2 then writeln(1) else;
   if (n mod 2 = 0) and (n > 2) then writeln(2) else
   if (n mod 2 = 1) and (check(n-2)) then writeln(2) else writeln(3);
end.

Const Finp='';
      Fout='';
Var n:longint;

Procedure Nhap;
Var f:Text;
    i:longint;
Begin
    assign(f,finp); reset(f);
    read(f,n);
    close(f);
End;
Function Solve:longint;
Var i:longint;
    lc:boolean;
Begin
    lc:=false;
    for i:=2 to trunc(sqrt(n)) do
        if n mod i=0 then
            begin
                lc:=true;
                break;
            end;
    if lc=false then exit(1);
    if n mod 2=1 then exit(3);
    if n mod 2=0 then exit(2);
End;
Procedure Xuat_Solve;
Var f:Text;
    res:longint;
Begin
    assign(f,fout); rewrite(f);
    res:=solve;
    write(f,res);
    close(f);
End;

Begin
    Nhap;
    Xuat_Solve;
End.

var
  i,j,n,m,k:longint;
begin
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  readln(n);
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=2 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;exit;end;
  if k=0 then write(2) else write(3);
  end;
  end.

program yan;
  var i,j,x,y,a,b,n,m:longint;
  function prov(a:longint):boolean;
    var i,j,x,y:longint;
    begin
      prov:=false;
      for i:=2 to round(sqrt(a)) do
        if a mod i=0 then
          begin
            prov:=true;
            break;
          end;
    end;
begin
  readln(n);
  if not prov(n) then begin write(1); exit; end;
  a:=n-2; b:=2;
  while a>0 do
    begin
      if prov(a) then begin dec(a); inc(b); end
      else
      begin
        inc(m);
        a:=b-2; b:=2;
      end;
    end;
  write(m+1);
end.

var d,x,ot:int64;
begin
readln(x);
if (x mod 2=0) and (x>4) then writeln(2);
if (x mod 2=1) and (x>5) then writeln(3);
if (x=2) then writeln(1);
if (x=3) then writeln(1);
if (x=4) then writeln(1);
if (x=5) then writeln(1);
End.

var n,i:int64;
    //t:array [1..1000000000] of longint;

function fun(n:int64):int64;
  var i,k:longint;
  begin
    k:=1;
    while k=1 do
      begin
        k:=0;
        for i:=trunc(sqrt(n)) downto 2 do
          if n mod i = 0 then begin dec(n); k:=1; break; end;
        if k=0 then exit(n);
      end;
  end;

begin
  readln(n);
  i:=0;

  while n > 0 do
    begin
      if i = 0 then n:=n-fun(n-1)
        else n:=n-fun(n);
      inc(i);
    end;

  writeln(i);

end.

var
  i,j,n,m,k:longint;
begin
read(n);
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=2 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;exit;end;
  if k=0 then write(2) else write(3);
  end;
  end.

program cf736B;
var n:longint;
function prime(x:longint):boolean;
var i:longint;
begin
  for i:=2 to n-1 do
  begin
    if i*i>n then exit(true);
    if n mod i=0 then exit(false);
  end;
  exit(true);
end;
begin
  readln(n);
  if prime(n) then write(1)
    else if n mod 2=0 then write(2)
      else if prime(n-2) then write(2)
        else write(3);
end.

var
  a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')
  else if (n mod 2=0) then write('2')
    else begin
      k:=0;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=0 then begin write('1'); exit; end;
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=1 then write('2') else write('3');
    end;
end.

var
  a,n,i:longint;
  t:boolean;
begin
  readln(n);
  if(n=1)or(n=2)then writeln(1)else
  if(n mod 2=0)then writeln(2)else
  begin
    t:=false;
    a:=trunc(sqrt(n));
    for i:=1 to a do
      if(n mod i)=0then
      begin
        t:=true;
        break
      end;
    if not t then
    begin
      writeln('1');
      halt
    end;
    t:=false;
    dec(n,2);
    a:=trunc(sqrt(n));
    for i:=1 to a do
      if (n)mod i=0 then
      begin
        t:=true;
        break
      end;
    if t then
      writeln(3) else writeln(2);
  end
end.

var n:longint;
procedure check;
var f,i:longint;
begin
 f:=0;
 for i:=2 to round(sqrt(n)) do
  if n mod i=0 then begin f:=1; break; end;
 if f=0 then begin write(1); halt; end;
end;
begin
read(n);
check;
write(2+n mod 2);
end.

var
 n,i,sum:longint;
begin
  readln(n);
  if n=1 then begin writeln(1);exit;end;
  if n mod 2=0 then begin writeln(2);exit;end;
  i:=2;
  while n>=i do
    begin
      if n mod i=0 then begin inc(sum);n:=n div i;end
        else inc(i);
    end;
  writeln(sum);
end.

var n,i:int64;

function fun(n,q:int64):int64;
  var i:longint; k:int64;
  begin
    k:=1;
    while k=1 do
      begin
        k:=0;
        for i:=round(sqrt(n)) downto 2 do
          if n mod i = 0 then begin dec(n); k:=1; break; end;
        if q-n=1 then begin dec(n); k:=1; end;
        if (k=0) then exit(n);
      end;
  end;

begin
  readln(n);
  i:=0;

  while n > 0 do
    begin   //writeln(fun(n,n));
      n:=n-fun(n,n);
      inc(i);
    end;

  writeln(i);

end.

                    const eps=0.0000000001;  besk=20000000000008;  nn=200000;
   label 1,2,3,4;
    type
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;
   i1,j1,k1, step, i,j:longint;
    aanew,bbnew:extended;
     ss:string;
    s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;
    ddminus, ppole:array[-1..2000,-1000..1502] of int64;
   text,text1,text2:array[-10..2000000] of char;
     ss1,ss2:string;
     ddd,dd:array[-1..40000,-1..10] of int64;
     marked:array[-100000..500000] of boolean;
    sss:string;ch:char;
    pole :array [-10..500,-10..500] of char;
    st2:array[0..nn] of string;
     v0,v1,t0:real;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
       flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function koll(pp:longint):longint;
label 43;
 var ot,i,t:longint;
aanew:extended; flag:boolean;
begin
 flag:=true;
   aanew:=pp; aanew:=sqrt(aanew);
   t:=round(aanew+0.01);
  for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;
 { writeln(flag);
 }
  if flag then begin ot:=1; goto 43;  end;
  if odd(pp) then  begin ot:=3; goto 43;  end;
  if not odd(pp) then  begin ot:=2; goto 43;  end;
43:
 koll:=ot;
end;

function prost(pp:longint):boolean;
var i:longint;flag:boolean;
 begin
   flag:=true;
    for i:=2 to min(pp-1,100000) do
     if pp mod i=0 then flag:=false;

   prost:=flag;
 end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    {   for i:=2 to 30  do writeln(i,' ',koll(i));

     for i:=2000000002 to 2000000010  do writeln(i,' ',koll(i));
     }

   {  for i:=2 to 100 do if prost(i) then write(i,' ');
     writeln;
    }
     if prost(pp-2) then tt:=2 else tt:=3;
    read(pp);
    writeln(min(koll(pp),tt));

   1:    close(output);
end.

var d,x,ot:int64;
begin
readln(x);
ot:=x;
d:=2;
while int64(d)*d<=x do
if x mod d=0 then begin
                        x:=x div d;
                        ot:=ot+1;
                        end
                else if d=2 then d:=3
                        else d:=d+2;
if x=ot then writeln(1) else begin
if (ot mod 2=0) and (ot>2) then writeln(2);
if (ot mod 2=1) and (ot>5) then writeln(3);
if (ot=2) then writeln(1);
if (ot=3) then writeln(1);
if (ot=5) then writeln(1);
end;
End.

var d,x,ot:int64;
begin
readln(x);
ot:=x;
d:=2;
while int64(d)*d<=x do
if x mod d=0 then begin
                        x:=x div d;

                        end
                else if d=2 then d:=3
                        else d:=d+2;
if x=ot then writeln(1) else begin
if (ot mod 2=0) and (ot>2) then writeln(2);
if (ot mod 2=1) and (ot>5) then writeln(3);
if (ot=2) then writeln(1);
if (ot=3) then writeln(1);
if (ot=5) then writeln(1);
end;
End.

program z1;
var a,b,c,d,i,j,k,l,m,n:longint;
begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n);
for i:=2 to round(sqrt(n)) do
 begin
 if n mod i=0 then a:=1;
 end;
if a=0 then write('1') else if n mod 2=0 then write('2') else write('3');
end.

program yan;
  var i,j,x,y,a,b,n,m:longint;
  function prov(a:longint):boolean;
    var i,j,x,y:longint;
    begin
      prov:=false;
      for i:=2 to round(sqrt(a)) do
        if a mod i=0 then
          begin
            prov:=true;
            break;
          end;
    end;
begin
  readln(n);
  //for n:=30 to 100 do
  //begin m:=0;
  if not prov(n) then begin writeln(1); exit; end;
  a:=n-2; b:=2;
  while a>0 do
    begin
      if not((not prov(a))and(not prov(b))and(b<=a div 2)) then begin dec(a); inc(b); end
      else
      begin
        inc(m);
        if not prov(b) then break;
        a:=b-2; b:=2;
      end;
    end;
  if prov(n) then writeln(m+1);//end;
end.

var d,x,ot:int64;
begin
readln(x);
if (x mod 2=0) and (x>4) then writeln(2);
if (x mod 2=1) and (x>5) then writeln(3);
if (x=2) then writeln(1);
if (x=3) then writeln(1);
if (x=4) then writeln(2);
if (x=5) then writeln(2);
End.

var
p,n,i:longint;
bol:boolean;
begin
readln(n);
if n mod 2 =  0 then writeln(2)
else begin
bol:=true;
    for i:=2 to round(sqrt(n)) do   if n mod i = 0 then bol:=false;
    if bol then writeln(1)
    else begin
    bol:=true;
    p:=n-2;
     for i:=2 to round(sqrt(p)) do   if p mod i = 0 then bol:=false;
     if bol then writeln(2)
     else
    writeln(3);

    end;
end;
end.

var
  n,i,j:longint;
  p:boolean;
begin
  read(n);
  if n<=2 then begin write(1); halt; end;
  p:=true;
  for i:=1 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then begin write(1); halt; end;
  p:=true;
  n:=n-2;
  for i:=1 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then write(2) else write(3);
end.

var n:longint;
begin
 read(n);
 write('1');
end.

var a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')
  else if (n mod 2=0) then write('2')
    else begin
      a:=trunc(sqrt(n));
      for i:=1 to a do if n mod i=0 then begin k:=1; break; end;
      if k=0 then begin write('1'); exit; end;
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=1 to a do if n mod i=0 then begin k:=1; break; end;
      if k=1 then write('3') else write('2');
    end;
end.

var n,i:int64;
    //t:array [1..1000000000] of longint;

function fun(n:int64):int64;
  var i,k:longint;
  begin
    k:=1;
    while k=1 do
      begin
        k:=0;
        for i:=trunc(sqrt(n)) downto 2 do
          if n mod i = 0 then begin dec(n); k:=1; break; end;
        if k=0 then exit(n);
      end;
  end;

begin
  readln(n);
  i:=0;

  while n > 0 do
    begin
      if i = 0 then n:=n-fun(n-1)
        else n:=n-fun(n);
      inc(i);
    end;

  writeln(i);

end.

var
 a,n,i,k:longint;
begin
  readln(n);
  if (n=1)or(n=2) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else
        begin
          a:=trunc(sqrt(n));
          for i:=1 to a do
            if n mod i=0 then begin k:=1;break;end;
          if k=0 then begin writeln(1);exit;end;
          a:=trunc(sqrt(n-2));
          for i:=1 to a do
            if n mod i=0 then begin writeln(3);exit;end;
          writeln(2);
        end;
end.

var
 n,i,sum:longint;
begin
  readln(n);
  if n=1 then begin writeln(1);exit;end;
  i:=2;
  while n>=i do
    begin
      if n mod i=0 then begin inc(sum);n:=n div i;end
        else inc(i);
    end;
  writeln(sum);
end.

var
  i,j,n,m,k:longint;
begin
read(n);
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=1 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;break;end;
  if k=0 then write(2) else write(3);
  end;
  end.

function prost (a:longint):boolean;
var i:longint; flag:boolean;
begin
flag:=true;
 for i:=2 to trunc(sqrt(a)) do
  if a mod i = 0 then begin flag:=false; break; end;
 prost:=flag;
end;

var n,k,c,a,b:longint;
begin
 read(n);
 if prost(n) then writeln(1) else
  if n mod 2 = 0 then writeln(2) else
   if prost(n-1) then writeln(2) else
    writeln(3);
end.

var a,n,i:longint;
    b:boolean;
begin
  read(n);
  if n<=2 then writeln(1)
  else if not(odd(n)) then write(2)
  else begin
      for i:=1 to trunc(sqrt(n-2)) do
       if (n mod i)=0 then begin b:=true;break; end;
      if b then begin write(1); exit; end;
      b:=false;
      for i:=1 to trunc(sqrt(n-2)) do if ((n-2) mod i)=0 then begin b:=true; break; end;
      if b then write(3) else write(2);
  end;
end.

uses    math;

var     f:array[1..1000000] of boolean;
        p:array[1..1000000] of longint;
        n,nP:longint;

procedure mofile;
begin
        assign(input,'codeforces.inp');
        assign(output,'codeforces.out');
        reset(input);
        rewrite(output);
end;

procedure dongfile;
begin
        close(input);
        close(output);
end;

procedure doc;
begin
        read(n);
end;

procedure sangNT(n:longint);
var     i,j:longint;
begin
        for i:=1 to n do f[i]:=true;
        f[1]:=false;
        for i:=2 to n do
            if f[i] then
            begin
                inc(nP);
                p[nP]:=i;
                for j:=2 to n div i do f[i*j]:=false;
            end;
end;

function NT(n:longint):boolean;
var     i:longint;
begin
        if n<=1000000 then exit(f[n]);
        for i:=1 to nP do
        begin
            if p[i]>trunc(sqrt(n)) then break;
            if n mod p[i]=0 then exit(false);
        end;
        exit(true);
end;

procedure xuly;
var     i,d:longint;
begin
        sangNT(1000000);
        i:=n+1;
        d:=0;
        while n>0 do
        begin
            i:=n;
            for i:=n downto 1 do
            begin
                if NT(i) and (n-i<>1) then
                begin
                        inc(d);
                        n:=n-i;
                        break;
                end;
            end;
        end;
        write(d);
end;

BEGIN

        doc;
        xuly;

END.

program cf736B;
var n:longint;
function prime(x:longint):boolean;
var i:longint;
begin
  for i:=2 to n-1 do
  begin
    if i*i>n then exit(true);
    if n mod i=0 then exit(false);
  end;
  exit(true);
end;
begin
  readln(n);
  if prime(n) then write(1)
    else if n mod 2=0 then write(2)
      else if prime(n-2) then write(2)
        else write(3);
end.

var
  i,j,n,m,k:longint;
begin
read(n);
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  for i:=1 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=1 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;break;end;
  if k=1 then write(3) else write(2);
  end;
  end.

var n:longint;
begin
read(n);
write(2+n mod 2);
end.

var
  n,i,j:longint;
  p:boolean;
begin
  read(n);
  if n<=2 then begin write(1); halt; end;
  p:=true;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then begin write(1); halt; end;
  p:=true;
  n:=n-2;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then write(2) else write(3);
end.

CONST FI='';
      FO='';
var m,n,i,j,k:longint;
procedure doc;
begin
     assign(input,fi);
     reset(input);
     read(n);
end;
function kt(x:longint):boolean;
var i:longint;
begin
     if x<2 then exit(false);
     if x=2 then exit(true);
     for i:=1 to trunc(sqrt(x)) do
     if x mod i=0 then exit(false);
     exit(true);
end;
procedure xuli;
begin
      if kt(n) then
      begin
            write(1);
            exit;
      end;

      if ( n mod 2=0) and kt(n-2) then
      begin
            write(2);
            exit;
      end
      else
      write(3);
end;
procedure inkq;
begin
      assign(output,fo);
      rewrite(output);
      xuli;
end;
begin
doc;

inkq;
end.

var
	n:longint;
function prime(x:longint):boolean;
var
	j,t:longint;
begin
	if x=1 then exit(false);
	t:=trunc(sqrt(x));
	for j:=2 to t do
		if x mod j=0 then exit(false);
	exit(true);
end;
begin
	readln(n);
	if (n=1) or (n=2) or (n=3) then
	begin
		writeln(1);
		halt;
	end;
	if n mod 2=0 then
	begin
		writeln(2);
		halt;
	end;
	if n mod 2=1 then
		if prime(n-2) then writeln(2)
		else writeln(3);
end.

var
  n,i,j:longint;
  p:boolean;
begin
  read(n);
  if n<=2 then begin write(1); halt; end;
  p:=true;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then begin write(1); halt; end;
  p:=true;
  n:=n-2;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin p:=false; break; end;
  if p then write(3) else write(2);
end.

var
  i,j,n,m,k:longint;
begin
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  readln(n);
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=2 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;exit;end;
  if k=0 then write(2) else write(3);
  end;
  end.

                    const eps=0.0000000001;  besk=20000000000008;  nn=200000;
   label 1,2,3,4;
    type
    mas=array [0..nn] of int64;   point=record x,y,z:real;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap;
    mass=array[0..nn] of int64;mass1=^mass;
    var tt,aa,bb,jj,kk,ii,xx,yy,ott,k,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,pp,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,s,smin,cen:int64;
   i1,j1,k1, step, i,j:longint;
    aanew,bbnew:extended;
     ss:string;
    s0,s1,d00,d01,d10,d11,a,b,right,aold,left,z,y,x,newc,d,c,nap:array[-10..600000] of int64;
    ddminus, ppole:array[-1..2000,-1000..1502] of int64;
   text,text1,text2:array[-10..2000000] of char;
     ss1,ss2:string;
     ddd,dd:array[-1..40000,-1..10] of int64;
     marked:array[-100000..500000] of boolean;
    sss:string;ch:char;
    pole :array [-10..500,-10..500] of char;
    st2:array[0..nn] of string;
     v0,v1,t0:real;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
       flag2,flag,flag1:boolean;
    function al(x,y:real):real; var t0,t1,p,s0,s1:real;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

function koll(pp:longint):longint;
label 43;
 var ot,i,t:longint;
aanew:extended; flag:boolean;
begin
 flag:=true;
   aanew:=pp; aanew:=sqrt(aanew);
   t:=round(aanew+0.01);
  for i:=2 to min(pp-1,100000) do if pp mod i=0 then flag:=false;
 { writeln(flag);
 }
  if flag then begin ot:=1; goto 43;  end;
  if odd(pp) then  begin ot:=3; goto 43;  end;
  if not odd(pp) then  begin ot:=2; goto 43;  end;
43:
 koll:=ot;
end;

function prost(pp:longint):boolean;
var i:longint;flag:boolean;
 begin
   flag:=true;
    for i:=2 to min(pp-1,100000) do
     if pp mod i=0 then flag:=false;

   prost:=flag;
 end;

begin
  {  assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
   }
    {   for i:=2 to 30  do writeln(i,' ',koll(i));

     for i:=2000000002 to 2000000010  do writeln(i,' ',koll(i));
     }

     if prost(pp-2) then tt:=2;
    read(pp);
    writeln(min(koll(pp),tt));

   1:    close(output);
end.

var
        n,i:longint;
        bz:boolean;
begin
        readln(n);
        bz:=false;
        for i:=1 to trunc(sqrt(n)) do
                if n mod i=0 then
                begin
                        bz:=true;
                        break;
                end;
        if bz=false then
        begin
                writeln(1);
                halt;
        end;
        if n mod 2=0 then
        begin
                writeln(2);
                halt;
        end;
        bz:=false;
        for i:=1 to trunc(sqrt(n-2)) do
                if (n-2) mod i=0 then
                begin
                        bz:=true;
                        break;
                end;
        if bz=false then writeln(2)
        else writeln(3);
end.

var n:longint;
procedure check;
var f,i:longint;
begin
 f:=0;
 for i:=2 to round(sqrt(n)) do
  if n mod i=0 then begin f:=1; break; end;
 if f=0 then begin write(1); halt; end;
end;
begin
read(n);
check;
write(2+n mod 2);
end.

var
  a,b,i,n,k,j:longint;
  function f(n:longint):longint;
  var a,b,i:longint;
  begin
    a:=0;
    for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then a:=1;
    f:=a;
  end;
begin
  read(n);
  if f(n)=0 then writeln(1) else
  if (n mod 2=0) and (f(n-2)=0) then writeln(2) else
  writeln(3);
end.

var n:int64;
function p(x:longint):boolean;
var i:longint;
begin
if x=2 then exit(false);
for i:=2 to trunc(sqrt(x)) do
  if x mod i=0 then exit(false);
exit(true);
end;
begin
readln(n);
if p(n) then writeln(1)
else if n mod 2=0 then writeln(2)
else if p(n-2) then writeln(2)
else writeln(3);
end.

function prost (a:longint):boolean;
var i:longint; flag:boolean;
begin
flag:=true;
 for i:=2 to trunc(sqrt(a)) do
  if a mod i = 0 then begin flag:=false; break; end;
 prost:=flag;
end;

var n,k,c,a,b:longint;
begin
 read(n);
 if prost(n) then writeln(1) else
  if n mod 2 = 0 then writeln(2) else
   if prost(n-1) then writeln(2) else
    writeln(3);
end.

var a,n,i,k:longint;
begin
  read(n);
  if (n=1)or(n=2) then write('1')
  else if (n mod 2=0) then write('2')
    else begin
      k:=0;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=0 then begin write('1'); exit; end;
      if k=1 then begin
      k:=0;
      n:=n-2;
      a:=trunc(sqrt(n));
      for i:=1 to a do if (n mod i)=0 then begin k:=1; break; end;
      if k=1 then write('3') else write('2');
      end;
    end;
end.

program nalogi;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  w : boolean;
  n, i, res : integer;

begin
  readln ( n );

  w := true;
  i := 3;

  if ( n = 2 ) then
    w := true
  else
  if ( n mod 2 <> 0 ) then
   while ( i <= trunc ( sqrt ( n ) ) ) do begin
      if ( n mod i = 0 ) then begin
        w := false;
        break;
      end;
      inc ( i, 2 );
    end
  else
    w := false;

  if ( w ) then
    res := 1
  else
    if ( n mod 2 = 0 ) then
      res := 2
  else
    res := 3;

  writeln ( res );

  readln;
end.

var n,i:int64;

function fun(n,q:int64):int64;
  var i,k:longint;
  begin
    k:=1;
    while k=1 do
      begin
        k:=0;
        for i:=trunc(sqrt(n)) downto 2 do
          if n mod i = 0 then begin dec(n); k:=1; break; end;
        if (k=0) and (k-n <> 1) then exit(n);
      end;
  end;

begin
  readln(n);
  i:=0;

  while n > 0 do
    begin
      n:=n-fun(n,n);
      inc(i);
    end;

  writeln(i);

end.

program z1;
var a,b,c,d,i,j,k,l,m,n:longint;
begin
//assign(input,'d:\input.txt'); reset(input);
//assign(output,'d:\output.txt'); rewrite(output);
readln(n);
for i:=2 to round(sqrt(n)) do
 begin
 if n mod i=0 then a:=1;
 end;
if a=0 then write('1') else if n mod 2=0 then write('2') else write('3');
end.

var n:longint;
function tfboys(n:longint):boolean;
var i:longint;
begin
  if n<2 then exit(false);
  for i:=2 to trunc(sqrt(n))  do
    if n mod i=0 then exit(false);
  exit(true);
end;

begin
  readln(n);
  if tfboys(n) then writeln(1)
  else if (n mod 2=0) and (tfboys(n-2)) then writeln(2)
  else writeln(3);
end.

var
  i,j,n,m,k:longint;
begin
read(n);
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=1 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;exit;end;
  if k=0 then write(2) else write(3);
  end;
  end.

var n, k : longint;

function isprime(n : longint) : Boolean;
var d : longint;
begin
isprime:=true;
d:=2;
	while d*d<=n do begin
	if n mod d=0 then begin isprime:=false; break; end;
  Inc(d);
  end;
end;

function Simp (n : longint) : longint;
begin
while n>0 do begin
if isprime(n) then begin Simp:=n; break; end;
Dec(n);
end;
end;

begin
k:=0;
readln(n);
while n>0 do begin
Inc(k);
n:=n-Simp(n);
end;
writeln(k);
end.

var
 n,m,i: longint;
 f: boolean;
begin
 readln(n);
 m:=trunc(sqrt(n));

 for i:=2 to m do if n mod i = 0 then
 begin
  f:=true;
  break;
 end;

 if not f then begin writeln(1); halt; end;

 if not odd(n) then writeln(2) else
 begin
  for i:=2 to m+1 do if (n+2) mod i = 0 then
  begin
   f:=true;
   break;
  end;

  if not f then writeln(2) else writeln(3);
 end;
end.

var
 a,n,i,k:longint;
begin
  readln(n);
  if (n=1)or(n=2) then writeln(1)
    else if n mod 2=0 then writeln(2)
      else
        begin
          for i:=1 to trunc(sqrt(n)) do
            if n mod i=0 then begin k:=1;break;end;
          if k=0 then begin writeln(1);exit;end;
          for i:=1 to trunc(sqrt(n-2)) do
            if (n-2) mod i=0 then begin writeln(3);exit;end;
          writeln(2);
        end;
end.

uses math;
const    fi = '735d.inp';
         fo = '735d.out';
         maxn = 1000005;
var
   n,t,sl:longint;
   d,a,f:array[1..maxn]of longint;

procedure enter;
var   i:longint;
begin
   readln(n);
end;
procedure sangnt;
var i,j:longint;
begin
   for i:=2 to trunc(sqrt(maxn)) do
   if d[i]=0 then
   begin
      j:=i*i;
      while(j<=maxn)do
      begin
         d[j]:=1; inc(j,i);
      end;
   end;
end;

function check(x:longint):boolean;
var j:longint;
begin
   if x<=maxn then  exit(d[x]=0);
   for j:=2 to trunc(sqrt(x)) do
   if x mod j=0 then exit(false);
   exit(true);
end;
function tinh(x:longint):longint;
var i:longint;
begin
   if x=0 then exit(0);
   if f[x]<>-1 then exit(f[x]);
   f[x]:=maxn;
   for i:=sl downto 1 do
   if x-a[i]>=0 then
   f[x]:=min(f[x],tinh(x-a[i])+1);
   exit(f[x]);
end;
procedure solve;
var   i:longint;
begin
   t:=0;
   repeat
      if (t<>1)and(check(n-t)) then break;
      inc(t);
   until 1=2;
    sl:=0;
   for i:=2 to t do
   if d[i]=0 then
   begin
      inc(sl);a[sl]:=i;
   end;

   fillchar(f,sizeof(f),255);
   writeln(tinh(t)+1);

end;

BEGIN
 //  assign(input,fi); reset(input);
 //  assign(output,fo); rewrite(output);
   enter;
     sangnt;
   solve;
   close(input); close(output);
END.

var
  i,j,n,m,k:longint;
begin
if (n=1)or(n=2) then write('1')
else if (n mod 2=0) then write('2')
else begin
      k:=0;
  readln(n);
  for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin k:=1;break;end;
    if k=0 then begin write(1);exit;end;
    k:=0;
  for i:=2 to trunc(sqrt(n-2)) do
    if n mod i=0 then begin k:=1;exit;end;
  if k=0 then write(2) else write(3);
  end;
  end.

var
n,i:longint;
bol:boolean;
begin
readln(n);
if n mod 2 =  0 then writeln(2)
else begin
bol:=true;
    for i:=2 to round(sqrt(n)) do   if n mod i = 0 then bol:=false;
    if bol then writeln(1)
    else
    writeln(3);
end;
end.

var d,x,ot:int64;
begin
readln(x);
if (x mod 2=0) and (x>4) then writeln(2);
if (x mod 2=1) and (x>5) then writeln(3);
if (x=2) then writeln(1);
if (x=3) then writeln(1);
if (x=4) then writeln(1);
if (x=5) then writeln(1);
End.

Program ILoveYou;
VAR n:int64;

function Prim(x : int64) : boolean;
VAR i:int64;
Begin

Prim:=true;
i:=2;
while (i <= sqrt(x)) do
Begin
if ((x mod i) = 0) then Begin Prim:=false; i:=x; end;
i:=i + 1;
end;

end;

Begin

Readln(n);
if Prim(n) then Writeln(1) else
Begin

if ((n mod 2) = 0) then Writeln(2) else Writeln(3);

end;

Readln;
END.

 var n,i:longint;
     b:boolean;
begin
 readln(n);
 b:=true;
 for i:=2 to round(sqrt(n)+1) do
   if n mod i = 0 then begin
     b:=false;
     break;
   end;
 if b then
   writeln(1);
 if not b then
   if n mod 2 = 0 then
     writeln(2)
   else
     writeln(3);
end.

var
 n,i,sum:longint;
begin
  readln(n);
  if n=1 then begin writeln(1);exit;end;
  i:=2;
  while n>=i do
    begin
      if n mod i<>0 then begin inc(sum);n:=n div i;end
        else inc(i);
    end;
  writeln(sum);
end.