N = int(eval(input()))

d = len(str(N))

s = [0 for k in range(100)]



for k in range(1,N+1):

    l = len(str(k))

    s[10*(k//(10**(l-1)))+k%10] += 1



ans = 0

for k in range(1,10):

    ans += s[k]**2



for x in range(1,10):

    for y in range(1,10):

        ans += s[x*10+y]*s[y*10+x]



print(ans)

N = int(eval(input()))



t = [0]*(100)

ans = 0

for k in range(1,N+1):

    if k%10 != 0:

        t[10*int(str(k)[0])+int(str(k)[-1])] += 1

for k in range(11,100):

    if k%10 != 0:

        ans += t[k]*t[10*(k%10)+k//10]

print(ans)

N = int(eval(input()))
d = len(str(N))
s = [0 for k in range(100)]
for k in range(1, N + 1):
    l = len(str(k))
    s[10 * (k // (10 ** (l - 1))) + k % 10] += 1
ans = 0
for k in range(1, 10):
    ans += s[k] ** 2
for x in range(1, 10):
    for y in range(1, 10):
        ans += s[x * 10 + y] * s[y * 10 + x]
print(ans)

N = int(eval(input()))
t = [0] * (100)
ans = 0
for k in range(1, N + 1):
    if k % 10 != 0:
        t[10 * int(str(k)[0]) + int(str(k)[-1])] += 1
for k in range(11, 100):
    if k % 10 != 0:
        ans += t[k] * t[10 * (k % 10) + k // 10]
print(ans)

-d = len(str(N)) -s = [0 for k in range(100)] +t = [0] * (100) +ans = 0 -    l = len(str(k)) -    s[10 * (k // (10 ** (l - 1))) + k % 10] += 1 -ans = 0 -for k in range(1, 10): -    ans += s[k] ** 2 -for x in range(1, 10): -    for y in range(1, 10): -        ans += s[x * 10 + y] * s[y * 10 + x] +    if k % 10 != 0: +        t[10 * int(str(k)[0]) + int(str(k)[-1])] += 1 +for k in range(11, 100): +    if k % 10 != 0: +        ans += t[k] * t[10 * (k % 10) + k // 10]