void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);

  int[] a;
  for(int i=1; i*(i+1)/2<=n; i++) a~=(i*(i+1)/2);
  if(n==a[$-1]){writeln(1); return;}
  foreach(e1; a)foreach(e2; a){
    if(n==(e1+e2)){writeln(2); return;}
  }
  writeln(3);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}