CodeEff/ECCO huggingface dataset:
# Original solution
import datetime

s = int(eval(input()))
hour = int(s / 60 / 60)
minute = int((s - (hour * 60 * 60)) / 60)
second = int((s - (hour * 60 * 60)) % 60)
print(("{0}:{1}:{2}".format(hour,minute,second)))

# Optimized solution
S = int(eval(input()))
h = S // 3600
m = S % 3600 // 60
s = S % 3600 % 60
print(("%d:%d:%d" % (h,m,s)))
# Original solution
import datetime

n = int(input().rstrip())


#??????
int_hour = n // 3600
int_minute = (n % 3600) // 60
int_second = n- int_hour*3600 - int_minute * 60

# ??????????????????
print(int_hour,int_minute, int_second, sep=":" )


# Optimized solution
n = int(input().rstrip())


#??????
int_hour = n // 3600
int_minute = (n % 3600) // 60
int_second = n- int_hour*3600 - int_minute * 60

# ??????????????????
print(int_hour,int_minute, int_second, sep=":" )
# Original solution
S = int(input())

if S >= 3600:
    h=S//3600
    m=S%3600//60
    s=S%60
elif 3600 > S >= 60:
    h=0
    m=S//60
    s=S%60
else:
    h=m=0
    s=S
print(h, m, s, sep=":")


# Optimized solution
s = int(input())
h = s // 3600
m = (s - h * 3600) // 60
s = s -  h * 3600 - m * 60
print(h, m, s, sep=":")
# Original solution
def main():
    x = eval(input())
    y = int(x)
    h, z = divmod(y, 3600)
    m, s = divmod(z, 60)
    
    print((str(h)+":"+str(m)+":"+str(s)))

if __name__ == "__main__":
    main()

# Optimized solution
S = int(input())
h, tmp = divmod(S, 3600)
m, s = divmod(tmp, 60)
print(h,m,s,sep=':')
# Original solution
s  = int(input())
print(s // 3600, end="")
print(":", end="")
print(s // 60 % 60, end="")
print(":", end="")
print(s % 60)


# Optimized solution
S = int(eval(input()))
h = S // 3600
S %= 3600
m = S // 60
s = S % 60
print(f"{h}:{m}:{s}")
# Original solution
t, s = divmod(int(eval(input())), 60)
h, m = divmod(t, 60)
print((str(h) + ':' + str(m) + ':' + str(s)))

# Optimized solution
t, s = divmod(int(input()), 60)
h, m = divmod(t, 60)
print(h, m, s, sep=':')
# Original solution
from math import modf
S = int(eval(input()))
decimal_min, h = modf(S/3600)
decimal_sec, m = modf(decimal_min * 60)
s = round(decimal_sec * 60)
print((str(int(h)) + ':' + str(int(m)) + ':' + str(s)))



# Optimized solution
S =int(eval(input()))
h = int(S // 3600)
m = int(S % 3600 // 60)
s = int(S % 3600 % 60)
print((str(h) + ':' + str(m) + ':' + str(s)))
# Original solution

S = int(input())

print(S//3600, S // 60 % 60,S%60, sep = ':')




# Optimized solution
n = eval(input())
print("%d:%d:%d"%(n/3600, n%3600/60, n%60))
# Original solution
a = int(eval(input()))
h = int(a / 3600)
m = int((a - h * 3600) / 60)
s = int(a - h * 3600 - m * 60)
print((":" .join(map(str, [h, m, s]))))

# Optimized solution
num = int(input())
print(int(num/3600), int((num%3600)/60), num%60, sep=":")
# Original solution
if __name__ == '__main__':
    time_in_second = int(eval(input()))

    hour = time_in_second // 3600
    minute = (time_in_second % 3600) // 60
    second = time_in_second % 60

    print(('{0:d}:{1:d}:{2:d}'.format(hour, minute, second)))

# Optimized solution
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    S = int(eval(input()))
    h = S // 3600
    m = (S % 3600) // 60
    s = S % 60

    print(('{}:{}:{}'.format(h, m, s)))


if __name__ == '__main__':
    main(sys.argv[1:])
# Original solution
s = int(eval(input()))
m, s = s // 60, s % 60
h, m = m // 60, m % 60
print((':'.join(map(str, [h,m,s]))))

# Optimized solution
s = int(eval(input()))

second = s % 60
s = s // 60
min = s % 60
hour = s // 60

print(f'{hour}:{min}:{second}')
# Original solution
x = int(input())
print(int(x / 3600), int(x / 60 % 60), int(x % 60), sep = ':')


# Optimized solution
x = int(input())
print(x // 3600, x // 60 % 60, x % 60, sep = ':')
# Original solution
import sys

if __name__ == '__main__':
    import doctest
    doctest.testmod()
    S = int(sys.stdin.read())
    h = S / 3600
    m = (S % 3600) / 60
    s = S % 60
    print("%d:%d:%d" % (h, m, s))


# Optimized solution
#!/usr/bin/env python
#-*- coding: utf-8 -*-

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D

if __name__ == '__main__':
    S = int(input())
    h = S / 3600
    m = (S % 3600) / 60
    s = S % 60
    print("%d:%d:%d" % (h, m, s))
# Original solution
while True :
  n, x = list(map(int, input().split()))
  if(n == 0 and x == 0) :
    break
  else :
    s = 0
    for i in range(1, n + 1) :
      for j in range(1, i) :
        for k in range(1, j) :
          if(i + j + k == x) :
            s += 1
          else :
            pass
    print(s)


# Optimized solution
while True :
    n, x = list(map(int, input().split()))
    
    if n == 0 :
        break
    else :
        cnt = 0
        
        for i in range(1, n - 1) :
            for j in range(i + 1, n) :
                for k in range(j + 1, n + 1) :
                    if i + j + k == x :
                        cnt += 1
                        
        print(cnt)
# Original solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    count += 1
    print(count)

# Optimized solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if x - (i + j + k) == 0:
                    count += 1
                if x - (i + j + k) < 0:
                    break
    print(count)
# Original solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            for k in range(j + 1 ,n + 1):
                if i + j + k == x: count += 1
    print(count)

# Optimized solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0: break
    count = 0
    for i in range(1,n - 1):
        for j in range(i + 1 ,n):
            for k in range(j + 1 ,n + 1):
                if i + j + k == x: 
                    count += 1
                    break 
    print(count)
# Original solution
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if (i + j + k) == x:
                    cnt += 1
    print(cnt)

# Optimized solution
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, min(n - 1, int(x / 3))):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if (i + j + k) == x:
                    cnt += 1
    print(cnt)
# Original solution
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    cnt = 0
    upper_max_value = min(x - 3, n)
    lower_max_value = max(int(x / 3), 3)
    for i in range(upper_max_value, lower_max_value - 1, -1):
        for j in range(i - 1, 1, -1):
            for k in range(j - 1, 0, -1):
                if (i + j + k) == x:
                    cnt += 1
    print(cnt)

# Optimized solution
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    max_a = min(x - 3, n)
    min_a = max(x // 3 + 1, 3)
    cnt = 0
    for i in range(min_a, max_a + 1):
        max_b = min(i - 1, x - i - 1)
        min_b = (x - i) // 2 + 1
        cnt += (max_b - min_b + 1)
    print(cnt)
# Original solution
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

# Optimized solution
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == s + m + e:
                    count += 1

    print(count)
# Original solution
while True:
    [n, m] = [int(x) for x in input().split()]
    if [n, m] == [0, 0]:
        break

    hoge = list(range(1, n + 1))

    data = []
    for x in range(n - 1, 1, -1):
        for y in range(x - 1, 0, -1):
            for z in range(y - 1, -1, -1):
                # print((x, y, z))
                s = hoge[x] + hoge[y] + hoge[z]
                if s < m:
                    break
                if s == m:
                    data.append(s)

    print((len(data)))

# Optimized solution
while True:
    [n, m] = [int(x) for x in input().split()]
    if [n, m] == [0, 0]:
        break

    data = []
    for x in range(n, 2, -1):
        for y in range(x - 1, 1, -1):
            for z in range(y - 1, 0, -1):
                s = x + y + z
                if s < m:
                    break
                if s == m:
                    data.append(s)

    print((len(data)))
# Original solution
while 1:
    k=input().split()
    n=int(k[0])
    x=int(k[1])
    if n==0 and x==0 :
        break
    m=0
    for i1 in range(1,n+1):
        for i2 in  range(1,n+1):
            for i3 in  range(1,n+1):
                if (i1!=i2 and i2!=i3) and (i3!=i1 and x==i1+i2+i3):
                    m+=1
    print((m//6))


# Optimized solution
while 1:
    k=input().split()
    n=int(k[0])
    x=int(k[1])
    if n==0 and x==0 :
        break
    m=0
    for i1 in range(1,n-1):
        for i2 in  range(i1+1,n):
            for i3 in  range(i2+1,n+1):
                if (i1!=i2 and i2!=i3) and (i3!=i1 and x==i1+i2+i3):
                    m+=1
    print(m)
# Original solution
#!/usr/local/env python3

import sys
from itertools import combinations


def find_all_subsets_of_target_sum(numbers, target_sum):
    subsets = []
    for x in range(len(numbers)):
        subsets.extend([
                combo for combo in combinations(numbers, x)
                if sum(combo) == target_sum
            ]
        )
    return subsets


def find_num_of_subset_with_x_elements(upper_bound, target_sum, x_elements):
    numbers = [int(number) for number in range(1, upper_bound+1)]
    subsets = find_all_subsets_of_target_sum(numbers, target_sum)
    subset_count = 0
    for subset in subsets:
        if len(subset) == x_elements:
            subset_count += 1
    return subset_count


def program_runner():
    while True:
        n, x = list(map(int, sys.stdin.readline().split()))
        if n == x == 0:
            break
        print((find_num_of_subset_with_x_elements(n, x, 3)))


def main():
    program_runner()


if __name__ == '__main__':
    main()

# Optimized solution
#!/usr/local/env python3

import sys


def main():
    while True:
        count = 0
        n, r = list(map(int, sys.stdin.readline().split()))
        if n == r == 0:
            break
        for n1 in range(1, n-1):
            for n2 in range(n1+1, n):
                for n3 in range(n2+1, n+1):
                    if n1 + n2 + n3 == r:
                        count += 1
        print(count)


if __name__ == '__main__':
    main()
# Original solution
from itertools import combinations

inputs = []
n,x = list(map(int,input().split()))
while n != 0 or x != 0:
     inputs.append((n,x))
     n,x = list(map(int,input().split()))

for n,x in inputs:
    print((len([c for c in combinations(list(range(1,n+1)),3) if sum(c) == x])))


# Optimized solution
from itertools import combinations

inputs = []
n,x = list(map(int,input().split()))
while n != 0 or x != 0:
     inputs.append((n,x))
     n,x = list(map(int,input().split()))

for n,x in inputs:
    print((len([0 for c in combinations(list(range(1,n+1)),3) if sum(c) == x])))
# Original solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    dataset = []
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                dataset.append([a,b,c])

    count = 0
    for data in dataset:
        if sum(data) == x:
            count += 1

    print(count)

# Optimized solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if sum([a,b,c]) == x:
                    count += 1

    print(count)
# Original solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                if sum([a,b,c]) == x:
                    count += 1

    print(count)

# Optimized solution
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    limit = n if n < x else x
    for a in range(1, limit + 1):
        for b in range(a + 1, limit + 1):
            for c in range(b + 1, limit + 1):
                if sum([a,b,c]) == x:
                    count += 1

    print(count)
# Original solution
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import timeit
import time
import sys
import io
import re
import math
#start = time.time()
#start = time.clock()
while True:
    l = []
    (n,x)=list(map(int, input().split()))
    if n==x==0:
        break
    ans=0
    for a in range(1,n+1):
        l.append(a)
    for i in l:
        if i > 98: break
        for j in l:
            if j > 99 or i+j>x: break
            p=0
            for k in l:
                p=i+j+k
                if (i != j and j != k and k != i) and p==x and i<j<k:
                    ans+=1
    print(ans)

#end = time.clock()
#print end - start

# Optimized solution
while 1:
    ans=0
    n,x=list(map(int,input().split()))
    if n:
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:ans+=1
    else:break
    print(ans)
# Original solution
while 1:
    ans=0
    n,x=list(map(int,input().split()))
    if n:
        for i in range(1,n-1):
            for j in range(i+1,n):
                for k in range(j+1,n+1):
                    if i+j+k==x:ans+=1
    else:break
    print(ans)

# Optimized solution
while 1:
    a=0
    n,x=list(map(int,input().split()))
    if n==0:break
    for i in range(1,n-1):
        for j in range(i+1,n):
            c=x-i-j
            if c>j and c<=n:a+=1
    print(a)
# Original solution
from itertools import combinations
while True:
 n,m=list(map(int,input().split()))
 if n==m==0: break
 print((sum(1 for p in combinations(list(range(1,n+1)),3) if sum(p)==m)))

# Optimized solution
while 1:
 n,x=list(map(int,input().split()))
 if n+x==0:break
 print((len([1 for i in range(3,n+1)for j in range(2,x-i)if x-i-j<j<i])))
# Original solution
while 1:
 n,x=list(map(int,input().split()))
 if n+x==0:break
 print((len([1 for i in range(3,n+1)for j in range(2,x-i)if x-i-j<j<i])))

# Optimized solution
while 1:
 n,x=list(map(int,input().split()))
 if n+x==0:break
 print((len([1 for i in range(1,n-1)for j in range(i+1,n)if j<x-i-j<=n])))
# Original solution
while True:
  n, x = list(map(int, [_ for _ in input().split()]))
  cnt = 0
  if n == x == 0:
    break

  for n1 in range(1, n+1):
    for n2 in range(2, n+1):
      for n3 in range(3, n+1):
        if n1 != n2 and n2 != n3 and n3 != n1:
          if n1+n2+n3 == x and n1 < n2 < n3:
            cnt += 1

  print(cnt)

# Optimized solution
while True:
  n, x = list(map(int, [_ for _ in input().split()]))
  cnt = 0
  if n == x == 0:
    break

  for n1 in range(1, n+1):
    for n2 in range(n1+1, n+1):
      for n3 in range(n2+1, n+1):
        if n1 != n2 and n2 != n3 and n3 != n1:
          if n1+n2+n3 == x:
            cnt += 1

  print(cnt)
# Original solution
a, b = (int(i) for i in input().split())
while a != 0 or b != 0:
    count = 0
    for i in range(1, a-1):
        for j in range(i+1 , a):
            for k in range(i+2, a+1):
                if i + j + k == b and i < j < k:
                    count += 1
    print(("{0}".format(count)))
    a, b = (int(i) for i in input().split())

# Optimized solution
a, b = (int(i) for i in input().split())
#0??¨0?????\??????????????´????????????????????????
while a != 0 or b != 0:
    count = 0
    #i?????????????????°???
    for i in range(1, a-1):
        #j?????????????????°???
        for j in range(i+1 , a):
            #k?????????????????°???
            for k in range(i+2, a+1):
                #??????????????´???????????????????????????
                if i + j + k == b and i < j < k:
                    count += 1
    print(("{0}".format(count)))
    a, b = (int(i) for i in input().split())
# Original solution
import itertools
while True:
    n,x = list(map(int,input().split()))
    if n==x==0: break
    li = list(itertools.combinations([i+1 for i in range(n)],3))
    ret = 0
    for i in range(len(li)):
        if sum(li[i]) == x: ret+= 1
    print(ret)

# Optimized solution
import itertools
while True:
    n,x = list(map(int,input().split()))
    if n==x==0: break
    ret = 0
    for i in itertools.combinations([i+1 for i in range(n)],3):
        if sum(i) == x: ret+= 1
    print(ret)
# Original solution
import itertools
while True:
    n,x = list(map(int,input().split()))
    if n==x==0: break
    ret = 0
    for i in itertools.combinations([i+1 for i in range(n)],3):
        if sum(i) == x: ret+= 1
    print(ret)

# Optimized solution
while True:
    n,x = list(map(int,input().split()))
    if n == x == 0: break
    ret = 0
    max = x - 2

    if n <= x: max = n  
    for _ in range(max):
        if max == 2: break
        mid = max - 1
        for _ in range(mid):
            min = x - max - mid

            if min <= 0: mid -= 1
            elif min >= mid:

                break
            else: 
                ret += 1
                mid -= 1
        max -= 1
    print(ret)
# Original solution
def how_many_ways(n, x):
    ways = 0
    for i in range(1, n-1):
        for j in range(i+1, n):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    ways += 1

    return ways

def main():
    while True:
        n, x = [int(x) for x in input().split()]
        if n == x == 0:
            break

        print((how_many_ways(n, x)))

if __name__ == '__main__':
    main()



# Optimized solution
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break

    count = 0

    for i in range(1, n+1):
        for j in range(i+1, n+1):
            k = x - i - j

            if not (j < k <= n):
                continue

            count += 1

    print(count)
# Original solution
while True:
    n, x = (int(x) for x in input().split())
    if (n, x) == (0, 0): break

    cnt = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    cnt += 1

    print(cnt)

# Optimized solution
while True:
    n, x = (int(x) for x in input().split())
    if (n, x) == (0, 0): break
    cnt = sum(1 for i in range(1, n+1) for j in range(i+1, n+1) for k in range(j+1, n+1) if i + j + k == x)
    print(cnt)
# Original solution
n, x = list(map(int, input().split()))

while n != 0 or x != 0:
	cnt = 0
	i = 1
	while i <= n - 2:
		j = i + 1
	#	if i >= x:
	#		break
		while j <= n - 1:
			k = j + 1
	#		if i + j >= x:
	#			break
			while k <= n:
	#			if i + j + k > x:
	#				break
				if i + j + k == x:
					cnt += 1
				k += 1
			j += 1
		i += 1
	print(cnt)
	n, x = list(map(int, input().split()))


# Optimized solution
n, x = list(map(int, input().split()))

while n != 0 or x != 0:
	cnt = 0
	i = 1
	while i <= n - 2:
		j = i + 1
		if i >= x:
			break
		while j <= n - 1:
			k = j + 1
			if i + j >= x:
				break
			while k <= n:
				if i + j + k > x:
					break
				if i + j + k == x:
					cnt += 1
				k += 1
			j += 1
		i += 1
	print(cnt)
	n, x = list(map(int, input().split()))
# Original solution
def solve(n,x):
    count = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i == j :
                continue
            for k in range(1,n+1):
                if j == k or i == k:
                    continue
                if i+j+k == x:
                    count += 1
    return count//6

while True:
    n,x = list(map(int,input().split()))
    if n == x == 0:
        break;
    print((solve(n,x)))

# Optimized solution
def solve(n,x):
    count = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            k = x - i - j
            if j < k and k <= n:
                count += 1
    return count

while True:
    n,x = list(map(int,input().split()))
    if n == x == 0:
        break;
    print((solve(n,x)))
# Original solution
import itertools
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    ans = 0
    for t in list(itertools.combinations([i + 1 for i in range(n)], 3)):
        if sum(t) == x:
            ans += 1
    print(ans)

# Optimized solution
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B "How many ways?" ????§£??????
# 
import itertools
while True:
    n, x = list(map(int, input().split()))
    if not n:
        break
    print((list(map(sum, itertools.combinations(list(range(1, n + 1)), 3))).count(x)))
# Original solution
import itertools
while(True):
    n, x = [int(i) for i in input().split()]
    if n == 0 and x == 0: break
    cnt = 0
    for li in itertools.combinations(list(range(1, n + 1)),3):
        if sum(li) == x: cnt += 1
    print(cnt)

# Optimized solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    cnt = 0
    for li in combinations(list(range(1, n + 1)), 3):
        if sum(li) == x:
            cnt += 1
    print(cnt)
# Original solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    cnt = 0
    for li in combinations(list(range(1, n + 1)), 3):
        if sum(li) == x:
            cnt += 1
    print(cnt)



# Optimized solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print((sum(1 for li in combinations(list(range(1, n + 1)), 3) if sum(li) == x)))
# Original solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print((sum(1 for li in combinations(list(range(1, n + 1)), 3) if sum(li) == x)))


# Optimized solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print((sum(1 for a, b, c in combinations(list(range(1, n + 1)), 3) if a + b + c == x)))
# Original solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print((sum(a + b + c == x for a, b, c in combinations(list(range(1, n + 1)), 3))))



# Optimized solution
from itertools import combinations
while True:
    n, x = list(map(int, input().split()))
    if n == x == 0:
        break
    print((len([1 for a, b, c in combinations(list(range(1, n + 1)), 3) if a + b + c == x])))