def prime(n) 
    return false if n==1
    return true if n==2
    return false if n%2==0
    max = (n.to_f ** 0.5 + 1.0).to_i
    for i in 1..max/2+1 do
        m = i*2+1 
        return false if m!=n and n%m==0
    end
    return true
end


while true
    t = STDIN.gets.to_i
    exit 0 if t==0
    num_triangle = 0
    #checking loop
    i,j=1,2
    k=t-(i+j)
    while i<=j and j<=k
        if prime(i) then
            while j<=k
                if i+j>k then
                    if prime(j) and prime(k) then
                        num_triangle = num_triangle + 1
                    end
                end
                #increment
                j=j+1
                k=k-1
            end 
        end
        i=i+1
        j=i
        k=t-(i+j)
    end
    print num_triangle,"\n"
end