# ABC 152 D

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

snm = lambda: list(map(str, input().split()))

nl = lambda: list(map(int, input().split()))

n=ni()

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



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

    sl=str(i)

    sl_s=int(sl[0])

    sl_e=int(sl[-1])

    c[sl_s][sl_e]+=1



ans=0

for i in range(1,10):

    for j in range(1,10):

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

print(ans)
n=int(eval(input()))

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

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

  a=str(a)

  c[int(a[-1])][int(a[0])]+=1

ans=0

for i in range(1,10):

  for j in range(1,10):

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

print(ans)



# ABC 152 D
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
snm = lambda: list(map(str, input().split()))
nl = lambda: list(map(int, input().split()))
n = ni()
c = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    sl = str(i)
    sl_s = int(sl[0])
    sl_e = int(sl[-1])
    c[sl_s][sl_e] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += c[i][j] * c[j][i]
print(ans)

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

-# ABC 152 D -si = lambda: eval(input()) -ni = lambda: int(eval(input())) -nm = lambda: list(map(int, input().split())) -snm = lambda: list(map(str, input().split())) -nl = lambda: list(map(int, input().split())) -n = ni() -c = [[0] * 10 for _ in range(10)] -for i in range(1, n + 1): -    sl = str(i) -    sl_s = int(sl[0]) -    sl_e = int(sl[-1]) -    c[sl_s][sl_e] += 1 +n = int(eval(input())) +c = [[0] * 10 for i in range(10)] +for a in range(1, n + 1): +    a = str(a) +    c[int(a[-1])][int(a[0])] += 1