#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 1000000
#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )

static int d[ 2 ][ N ];

static int
dpFSA (
  int *k_operafan,
  int n
  )
{
  int i;

  if ( ~k_operafan[ n ] ) ;
  else
  {
    k_operafan[ n ] = n;
    for ( i = 2; i < n; ++i )
    {
      k_operafan[ n ]
        = MIN( k_operafan[ n ]
             , dpFSA ( k_operafan, i ) + dpFSA ( k_operafan, n - i ) );
    }
  }

  return ( k_operafan[ n ] );
}

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int i;

  /* メモ化配列初期化 */
  memset ( d, -1, sizeof ( d ) );
  for ( i = 1; ; ++i )
  {
    const int c = i * ( i + 1 ) * ( i + 2 ) / 6;

    if ( c >= N )
      break ;

    d[ 0 ][ c ] = 1;
    if ( c % 2 == 1 )
    {
      d[ 1 ][ c ] = 1;
    }
  }

  for ( ; ; )
  {
    int n;

    scanf ( "%d", &n );
    if ( n == 0 ) break ;

    printf ( "%d %d\n", dpFSA ( d[ 0 ], n ), dpFSA ( d[ 1 ], n ) );
  }

  return ( EXIT_SUCCESS );
}