n = int(eval(input()))



ab = {}

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

    t = str(i)

    if (t[0], t[-1]) in ab:

        ab[(t[0], t[-1])] += 1

    else:

        ab[(t[0], t[-1])] = 1

#print(ab)

ans = 0

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

    t = str(i)

    if (t[-1], t[0]) in ab:

        ans += ab[(t[-1], t[0])]

print(ans)

from collections import defaultdict

n = int(eval(input()))

counter = defaultdict(int)



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

    t = str(i)

    counter[(t[0], t[-1])] += 1



ans = 0

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

    t = str(i)

    ans += counter[(t[-1], t[0])]

print(ans)





n = int(eval(input()))
ab = {}
for i in range(1, n + 1):
    t = str(i)
    if (t[0], t[-1]) in ab:
        ab[(t[0], t[-1])] += 1
    else:
        ab[(t[0], t[-1])] = 1
# print(ab)
ans = 0
for i in range(1, n + 1):
    t = str(i)
    if (t[-1], t[0]) in ab:
        ans += ab[(t[-1], t[0])]
print(ans)

from collections import defaultdict

n = int(eval(input()))
counter = defaultdict(int)
for i in range(1, n + 1):
    t = str(i)
    counter[(t[0], t[-1])] += 1
ans = 0
for i in range(1, n + 1):
    t = str(i)
    ans += counter[(t[-1], t[0])]
print(ans)

+from collections import defaultdict + -ab = {} +counter = defaultdict(int) -    if (t[0], t[-1]) in ab: -        ab[(t[0], t[-1])] += 1 -    else: -        ab[(t[0], t[-1])] = 1 -# print(ab) +    counter[(t[0], t[-1])] += 1 -    if (t[-1], t[0]) in ab: -        ans += ab[(t[-1], t[0])] +    ans += counter[(t[-1], t[0])]