/*
  AOJ 2039
  Title:Space Coconut Crab II
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define mydiff(x,y) (((x)>(y))?(x-y):(y-x))
char prime64K[65536];

int prime256[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,
67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,
241,251};
int memo[30000];

make_furui()
{
  int i,j,pr;
        memset(prime64K,-1,65536);
        prime64K[0]=prime64K[1]=0;
	
        for(i=0;i<sizeof(prime256);i++)
	  {
	    pr=prime256[i];
	    if(pr==0)
	      break;
	    for(j=2;pr*j<65536;j++)
		prime64K[pr*j]=0;

	  }
	
}


main()
{
  int i,j,k,T,ret;
  make_furui();

  while(scanf("%d",&T)  && T)
    {
      for(i=ret=0;i<=T/3;i++)
	if(prime64K[i])
	  {
	    for(j=i;j<=T-i;j++)
	      if(prime64K[j])
		{
		  k=T-i-j;
		  if(prime64K[k] && mydiff(i,j)<k && i+j > k && j<=k)
		    {
		      ret++;
		    }
		}
	  }
  printf("%d\n",ret);
    }
  return(0);
}