import sys



read = sys.stdin.buffer.read

input = sys.stdin.buffer.readline

inputs = sys.stdin.buffer.readlines





#mod=10**9+7

# rstrip().decode('utf-8')

# map(int,input().split())

#import numpy as np





def main():

	n=int(eval(input()))

	

	ans1=0

	ans2=0

	

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

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

		b=i%10

		

		if b==0:

			continue

		k=len(str(i))

		if k==1:

			ans2+=1

		elif a>b:

			ans1+=(10**(k-1)-1)//9

		elif a<b:

			ans1+=(10**(k-2)-1)//9

		else:

			ans1+=(10**(k-2)-1)//9+1+(int(str(i)[1:])-a)//10

			ans2+=1

	print((ans1*2+ans2))

	

	

	

	

	





if __name__ == "__main__":

	main()

import sys

#input = sys.stdin.readline

input = sys.stdin.buffer.readline



# mod=10**9+7

# rstrip().decode('utf-8')

# map(int,input().split())

#import numpy as np





def main():

	li=[[0]*10 for i in range(10)]

	n=int(eval(input()))

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

		i=str(i)

		li[int(i[0])][int(i[-1])]+=1



	ans=0



	for i in range(1,10):

		for j in range(1,10):

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



	print(ans)

































if __name__ == "__main__":

	main()

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines
# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np
def main():
    n = int(eval(input()))
    ans1 = 0
    ans2 = 0
    for i in range(1, n + 1):
        a = int(str(i)[0])
        b = i % 10
        if b == 0:
            continue
        k = len(str(i))
        if k == 1:
            ans2 += 1
        elif a > b:
            ans1 += (10 ** (k - 1) - 1) // 9
        elif a < b:
            ans1 += (10 ** (k - 2) - 1) // 9
        else:
            ans1 += (10 ** (k - 2) - 1) // 9 + 1 + (int(str(i)[1:]) - a) // 10
            ans2 += 1
    print((ans1 * 2 + ans2))


if __name__ == "__main__":
    main()

import sys

# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np
def main():
    li = [[0] * 10 for i in range(10)]
    n = int(eval(input()))
    for i in range(1, n + 1):
        i = str(i)
        li[int(i[0])][int(i[-1])] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += li[i][j] * li[j][i]
    print(ans)


if __name__ == "__main__":
    main()

-read = sys.stdin.buffer.read +# input = sys.stdin.readline -inputs = sys.stdin.buffer.readlines +    li = [[0] * 10 for i in range(10)] -    ans1 = 0 -    ans2 = 0 -        a = int(str(i)[0]) -        b = i % 10 -        if b == 0: -            continue -        k = len(str(i)) -        if k == 1: -            ans2 += 1 -        elif a > b: -            ans1 += (10 ** (k - 1) - 1) // 9 -        elif a < b: -            ans1 += (10 ** (k - 2) - 1) // 9 -        else: -            ans1 += (10 ** (k - 2) - 1) // 9 + 1 + (int(str(i)[1:]) - a) // 10 -            ans2 += 1 -    print((ans1 * 2 + ans2)) +        i = str(i) +        li[int(i[0])][int(i[-1])] += 1 +    ans = 0 +    for i in range(1, 10): +        for j in range(1, 10): +            ans += li[i][j] * li[j][i] +    print(ans)