Buggy python submission (verdict: Runtime Error):
while 1:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    a =[]
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            for k in range(3, n + 1):
                if i + j + k == x:
                    if i != j:
                        if j != k:
                            if i != k:
                                a.append([i, j, k])
    b = []
    for i in a:
        b.append(sorted(i))

    c = []
    c = sorted(b)

    cnt = 1
    t = c[0]
    for i in c:
        if t != i:
            cnt += 1
            t = i
    print(cnt)

Fixed submission:
import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)

Buggy python submission (verdict: Runtime Error):
while 1:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    a =[]
    for i in range(1, n + 1):
        for j in range(2, n + 1):
            for k in range(3, n + 1):
                if i + j + k == x:
                    if i != j:
                        if j != k:
                            if i != k:
                                a.append([i, j, k])
    b = []
    for i in a:
        b.append(sorted(i))

    c = []
    c = sorted(b)

    cnt = 1
    t = c[0]
    for i in c:
        if t != i:
            cnt += 1
            t = i
    print(cnt)
    

Fixed submission:
import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
while 1:
    if n == 0 and x == 0:
        break
    s = []
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if i + j + k == x\
                and i != j != k\
                and i != j and i != k and j != k:
                    sort = sorted([i, j, k])
                    if sort not in s:
                        s.append(sort)
    print(len(s))
    n, x = map(int, input().split())

Fixed submission:
import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
while 1:
    if n == 0 and x == 0:
        break
    s = []
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if i + j + k == x\
                and i != j != k\
                and i != j and i != k and j != k:
                    sort = sorted([i, j, k])
                    if sort not in s:
                        s.append(sort)
    print(len(s))
    n, x = map(int, input().split())

Fixed submission:
import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
while True:
    if n == 0 and x == 0:
        break
    cnt = 0
    sort_list = []
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if i + j + k == x\
                and i != j != k\
                and i != j and i != k and j != k:
                    sort = sorted([i, j, k])
                    if sort not in sort_list:
                        sort_list.append(sort)
                        cnt += 1
    print(cnt)
    n, x = map(int, input().split())

Fixed submission:
import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    a = []
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                if i == j == k\
                or i == j\
                or j == k\
                or i ==k:
                    continue
                if i + j + k == x:
                    sort = sorted([i, j, k])
                    if sort not in a:
                        a.append(sort)
    print(len(a))

Fixed submission:
import itertools
while True:
    n, x = map(int, input().split())
    if n == 0\
    and x == 0:
        break

    a = [i for i in range(1, n+1)]
    b = [i for i in itertools.combinations(a, 3)]
    c = 0
    cnt = 0
    for i in range(len(b)):
        for j in range(3):
            c += b[i][j]
        if c == x:
            cnt += 1
        c = 0
    print(cnt)