n = int(eval(input()));l=[0 for _ in range(100)]

for i in range(1,n+1):

    l[int(str(i)[0]+str(i)[-1])]+=1

print((sum([l[i*10+j]*l[j*10+i]for i in range(10) for j in range(10)])))
l=[0 for _ in range(100)];r=list(range(10))

for i in range(1,int(eval(input()))+1):

    s=str(i);l[int(s[0]+s[-1])]+=1

print((sum([l[i*10+j]*l[j*10+i]for i in r for j in r])))
n = int(eval(input()))
l = [0 for _ in range(100)]
for i in range(1, n + 1):
    l[int(str(i)[0] + str(i)[-1])] += 1
print((sum([l[i * 10 + j] * l[j * 10 + i] for i in range(10) for j in range(10)])))

l = [0 for _ in range(100)]
r = list(range(10))
for i in range(1, int(eval(input())) + 1):
    s = str(i)
    l[int(s[0] + s[-1])] += 1
print((sum([l[i * 10 + j] * l[j * 10 + i] for i in r for j in r])))

-n = int(eval(input())) -for i in range(1, n + 1): -    l[int(str(i)[0] + str(i)[-1])] += 1 -print((sum([l[i * 10 + j] * l[j * 10 + i] for i in range(10) for j in range(10)]))) +r = list(range(10)) +for i in range(1, int(eval(input())) + 1): +    s = str(i) +    l[int(s[0] + s[-1])] += 1 +print((sum([l[i * 10 + j] * l[j * 10 + i] for i in r for j in r])))