n = int(eval(input()))

ans=0

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

    a=str(i)[0]

    b=str(i)[-1]

    for digit in range(1,7):

        if digit == 1:

            if a==b:

                ans+=1

        elif b!='0':

            mn = int(b+'0'*(digit-2)+a)

            mx = int(b+'9'*(digit-2)+a)

            if mn>n:

                break

            if mx<=n:

                ans+=10**(digit-2)

            else:

                ns=str(n)

                for j in range(1,len(ns)-1):

                    ans+=int(ns[j])*10**(max(digit-2-j,0))

                if ns[-1]>=a:

                    ans+=1

                break





print(ans)







n = int(eval(input()))

ans=0

mp=[[0]*10 for _ in range(10)]

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

    a=int(str(i)[0])

    b=int(str(i)[-1])

    mp[a][b]+=1



for i in range(10):

    for j in range(10):

        ans+=mp[i][j]*mp[j][i]

    





print(ans)







n = int(eval(input()))
ans = 0
for i in range(1, n + 1):
    a = str(i)[0]
    b = str(i)[-1]
    for digit in range(1, 7):
        if digit == 1:
            if a == b:
                ans += 1
        elif b != "0":
            mn = int(b + "0" * (digit - 2) + a)
            mx = int(b + "9" * (digit - 2) + a)
            if mn > n:
                break
            if mx <= n:
                ans += 10 ** (digit - 2)
            else:
                ns = str(n)
                for j in range(1, len(ns) - 1):
                    ans += int(ns[j]) * 10 ** (max(digit - 2 - j, 0))
                if ns[-1] >= a:
                    ans += 1
                break
print(ans)

n = int(eval(input()))
ans = 0
mp = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    mp[a][b] += 1
for i in range(10):
    for j in range(10):
        ans += mp[i][j] * mp[j][i]
print(ans)

+mp = [[0] * 10 for _ in range(10)] -    a = str(i)[0] -    b = str(i)[-1] -    for digit in range(1, 7): -        if digit == 1: -            if a == b: -                ans += 1 -        elif b != "0": -            mn = int(b + "0" * (digit - 2) + a) -            mx = int(b + "9" * (digit - 2) + a) -            if mn > n: -                break -            if mx <= n: -                ans += 10 ** (digit - 2) -            else: -                ns = str(n) -                for j in range(1, len(ns) - 1): -                    ans += int(ns[j]) * 10 ** (max(digit - 2 - j, 0)) -                if ns[-1] >= a: -                    ans += 1 -                break +    a = int(str(i)[0]) +    b = int(str(i)[-1]) +    mp[a][b] += 1 +for i in range(10): +    for j in range(10): +        ans += mp[i][j] * mp[j][i]