#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 ];

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

  memset ( k_operafan, -1, sizeof ( k_operafan ) );
  k_operafan[ 0 ][ 0 ] = k_operafan[ 1 ][ 0 ] = 0;
  for ( mode = 0; mode <= 1; ++mode )
  for ( i = 1; i < N; ++i )
  {
    k_operafan[ mode ][ i ] = i;
    for ( j = 1; ; ++j )
    {
      const int c = j * ( j + 1 ) * ( j + 2 ) / 6;

      if ( i - c < 0 )
        break ;
      if ( mode && ( c % 2 == 0 ) )
        continue ;

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

  for ( ; ; )
  {
    int n;

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

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

  return ( EXIT_SUCCESS );
}