import java.io.*; import java.util.*; public class Crab2Slower { private static final int LMAX = 100000; private static final Scanner cin = new Scanner(System.in); public static void main(String[] args) { boolean[] isPrime; { isPrime = new boolean[LMAX+1]; Arrays.fill(isPrime, true); isPrime[0] = false; isPrime[1] = false; for(int i = 2; i <= LMAX; i++) { if(isPrime[i]) { for(int j = i + i; j <= LMAX; j += i) { isPrime[j] = false; } } } } for(int l; (l = cin.nextInt()) != 0; ) { int count = 0; for(int a = 1; a <= l; a++) { if(!isPrime[a]) continue; for(int b = a; b <= l; b++) { int c = l - a - b; if(b > c) break; if(!isPrime[b]) continue; if(!isPrime[c]) continue; if( a + b <= c) continue; if( b + c <= a) continue; if( c + a <= b) continue; count++; } } System.out.println(count); } } }