def min(a,b)
  if a<b
    return a
  else
    return b
  end
end
def make_array(pol,odd_pol)
  i=1
  while pol[-1]<1000000
    i+=1
    if (s=(i*(i+1)*(i+2))/6)%2==1
      odd_pol.push(s)
    end
    pol.push((i*(i+1)*(i+2))/6)
  end
  return [pol,odd_pol]
end
def solve(x,pol)
  l=pol.length
  ans=Array.new(x+1,1000000)
  ans[0]=0
  for i in 0..x
    for j in 0..l-1
      if i>=pol[l-1-j]
        ans[i]=min(ans[i],ans[i-pol[l-1-j]]+1)
      end
    end
  end
  return ans[x]
end
def odd_solve(x,odd_pol)
  l=odd_pol.length
  ans=Array.new(x+1,1000000)
  ans[0]=0
  for i in 0..x
    for j in 0..l-1
      if i>=odd_pol[l-1-j]
        ans[i]=min(ans[i],ans[i-odd_pol[l-1-j]]+1)
      end
    end
  end
  return ans[x]
end

pol=make_array([1],[1])[0]
odd=make_array([1],[1])[1]
while true
  n=gets.to_i
  if n==0
    break
  end
  print solve(n,pol)," ",odd_solve(n,odd),"\n"
end