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

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

static int k_operafan[ 2 ][ N ];

static int
dpFSA (
  int mode,
  int n
  )
{
  int i;

  if ( ~k_operafan[ mode ][ n ] ) ;
  else
  {
    k_operafan[ mode ][ n ] = n;
    for ( i = 1; ; ++i )
    {
      const int c = i * ( i + 1 ) * ( i + 2 ) / 6;

      if ( c > n )
        break ;
      if ( mode && ( c % 2 == 0 ) )
        continue ;

      k_operafan[ mode ][ n ] = MIN( k_operafan[ mode ][ n ]
                                   , dpFSA ( mode, n - c ) + 1 );
    }
  }

  return ( k_operafan[ mode ][ n ] );
}

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

  memset ( k_operafan, -1, sizeof ( k_operafan ) );
  k_operafan[ 0 ][ 0 ] = k_operafan[ 1 ][ 0 ] = 0;

  for ( ; ; )
  {
    int n;

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

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

  return ( EXIT_SUCCESS );
}