import scala.io.StdIn.readInt

object Main {
  val n = 30000
  val primes = Array.tabulate(n+1) { _ % 2 }

  def sieve() = {
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    }
    for(i<-2 to n if primes(i)==1 ) yield i
  }

  def main(args:Array[String]) = {
    var n = 0
    val p = sieve()
    while({n=readInt;n}!=0) {
      var count = 0
      for(i<-p) {
        for(j<-p if j>=i) {
          if(n >=2*j+i && n<=2*i+2*j && primes(n-i-j)==1){
            count+=1
          }
        }
      }
      println(count)
    }
  }
}