S=eval(input())

N=int(S)

n=len(S)





ans=0

p=[1,10,100,1000,10000,100000]



for i in range(N+1):#数iに対する相手を探す

    ii=str(i)

    a=int(ii[0])

    b=int(ii[-1])

    if a*b!=0:

        if a==b:#a**aの形なら1桁の答えaが存在

            ans+=1

        for j in range(2,n+1):#桁数

            if j<n:

                ans+=p[j-2]

                #print(i,j,n,ans)

            elif j==n:

                floor=b*p[j-1]+a

                if j==2:

                    ceil=floor

                else:

                    ceil=floor+p[j-1]-p[1]

                #print(i,j,floor,ceil)

                if N>=ceil:

                    ans+=p[j-2]

                    #print(i,j,n,ans)

                elif N<floor:

                    continue

                else:#floorとceilの間

                    ans+=(N-floor)//10+1

                    #print(i,j,n,ans)

    #print("i,ans:{},{}".format(i,ans))

                    

print(ans)
S=eval(input())

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

N=int(S)



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

    ii=str(i)

    a=int(ii[0])

    b=int(ii[-1])

    TT[a][b]+=1

    

ans=0

for i in range(10):

    for j in range(10):

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

        

print(ans)
S = eval(input())
N = int(S)
n = len(S)
ans = 0
p = [1, 10, 100, 1000, 10000, 100000]
for i in range(N + 1):  # 数iに対する相手を探す
    ii = str(i)
    a = int(ii[0])
    b = int(ii[-1])
    if a * b != 0:
        if a == b:  # a**aの形なら1桁の答えaが存在
            ans += 1
        for j in range(2, n + 1):  # 桁数
            if j < n:
                ans += p[j - 2]
                # print(i,j,n,ans)
            elif j == n:
                floor = b * p[j - 1] + a
                if j == 2:
                    ceil = floor
                else:
                    ceil = floor + p[j - 1] - p[1]
                # print(i,j,floor,ceil)
                if N >= ceil:
                    ans += p[j - 2]
                    # print(i,j,n,ans)
                elif N < floor:
                    continue
                else:  # floorとceilの間
                    ans += (N - floor) // 10 + 1
                    # print(i,j,n,ans)
    # print("i,ans:{},{}".format(i,ans))
print(ans)

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

+TT = [[0] * 10 for _ in range(10)] -n = len(S) -ans = 0 -p = [1, 10, 100, 1000, 10000, 100000] -for i in range(N + 1):  # 数iに対する相手を探す +for i in range(1, N + 1): -    if a * b != 0: -        if a == b:  # a**aの形なら1桁の答えaが存在 -            ans += 1 -        for j in range(2, n + 1):  # 桁数 -            if j < n: -                ans += p[j - 2] -                # print(i,j,n,ans) -            elif j == n: -                floor = b * p[j - 1] + a -                if j == 2: -                    ceil = floor -                else: -                    ceil = floor + p[j - 1] - p[1] -                # print(i,j,floor,ceil) -                if N >= ceil: -                    ans += p[j - 2] -                    # print(i,j,n,ans) -                elif N < floor: -                    continue -                else:  # floorとceilの間 -                    ans += (N - floor) // 10 + 1 -                    # print(i,j,n,ans) -    # print("i,ans:{},{}".format(i,ans)) +    TT[a][b] += 1 +ans = 0 +for i in range(10): +    for j in range(10): +        ans += TT[i][j] * TT[j][i]