N = int(eval(input()))



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



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

  s = str(i)

  id1 = int(s[0])

  id2 = int(s[-1])

  table[id1][id2] += 1



ans = 0

for i in range(10):

  for j in range(10):

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



print(ans)
N = eval(input())

m = len(N)



a0 = int(N[0])

a1 = int(N[-1])



ans = 0

if m == 1:

  ans = int(N)

else:

  mid = (int(N[1:]) - a1)//10

  t = 10**(m-2)

  ans = 9

  ans += ((a0-1)*t) * 2

  ans += (mid + (a1>=a0)) * 2

  ans += ((a0-1)*t)**2

  ans += ((mid*(a0-1) + min(a0-1, a1))*t) * 2

  ans += (mid + (a1>=a0))**2

  if m >= 3:

    ans += (t - 1) * 2

    ans += ((a0-1)*(t - 1)*t) * 2

    ans += (mid * (t - 1)) * 2

    ans += (a1 * (t - 1)//9) * 2

    ans += (t - 1)**2



print(ans)
N = int(eval(input()))
table = [[0] * 10 for i in range(10)]
for i in range(1, N + 1):
    s = str(i)
    id1 = int(s[0])
    id2 = int(s[-1])
    table[id1][id2] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += table[i][j] * table[j][i]
print(ans)

N = eval(input())
m = len(N)
a0 = int(N[0])
a1 = int(N[-1])
ans = 0
if m == 1:
    ans = int(N)
else:
    mid = (int(N[1:]) - a1) // 10
    t = 10 ** (m - 2)
    ans = 9
    ans += ((a0 - 1) * t) * 2
    ans += (mid + (a1 >= a0)) * 2
    ans += ((a0 - 1) * t) ** 2
    ans += ((mid * (a0 - 1) + min(a0 - 1, a1)) * t) * 2
    ans += (mid + (a1 >= a0)) ** 2
    if m >= 3:
        ans += (t - 1) * 2
        ans += ((a0 - 1) * (t - 1) * t) * 2
        ans += (mid * (t - 1)) * 2
        ans += (a1 * (t - 1) // 9) * 2
        ans += (t - 1) ** 2
print(ans)

-N = int(eval(input())) -table = [[0] * 10 for i in range(10)] -for i in range(1, N + 1): -    s = str(i) -    id1 = int(s[0]) -    id2 = int(s[-1]) -    table[id1][id2] += 1 +N = eval(input()) +m = len(N) +a0 = int(N[0]) +a1 = int(N[-1]) -for i in range(10): -    for j in range(10): -        ans += table[i][j] * table[j][i] +if m == 1: +    ans = int(N) +else: +    mid = (int(N[1:]) - a1) // 10 +    t = 10 ** (m - 2) +    ans = 9 +    ans += ((a0 - 1) * t) * 2 +    ans += (mid + (a1 >= a0)) * 2 +    ans += ((a0 - 1) * t) ** 2 +    ans += ((mid * (a0 - 1) + min(a0 - 1, a1)) * t) * 2 +    ans += (mid + (a1 >= a0)) ** 2 +    if m >= 3: +        ans += (t - 1) * 2 +        ans += ((a0 - 1) * (t - 1) * t) * 2 +        ans += (mid * (t - 1)) * 2 +        ans += (a1 * (t - 1) // 9) * 2 +        ans += (t - 1) ** 2