n=int(eval(input()))

cnt=[[0]*10 for i in range(10)] #(10,10)サイズの配列

ret = 0



def hoge(m):

    #return m[-1],m[0]

    return (m%10, int(str(m)[0]))



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

    a,b = hoge(k)

    cnt[a][b] += 1    



for i in range(1,10):

    for j in range(1,10):

        ret += cnt[i][j] * cnt[j][i]



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



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



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

    now = str(i)

    pre, pos = int(now[0]), int(now[-1])

    if pos == 0: continue

    count[pre][pos] += 1



res = 0

for i in range(1, 10):

    for j in range(1, 10):

        res += count[i][j] * count[j][i]



print(res)



n = int(eval(input()))
cnt = [[0] * 10 for i in range(10)]  # (10,10)サイズの配列
ret = 0


def hoge(m):
    # return m[-1],m[0]
    return (m % 10, int(str(m)[0]))


for k in range(1, n + 1):
    a, b = hoge(k)
    cnt[a][b] += 1
for i in range(1, 10):
    for j in range(1, 10):
        ret += cnt[i][j] * cnt[j][i]
print(ret)

n = int(eval(input()))
count = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    now = str(i)
    pre, pos = int(now[0]), int(now[-1])
    if pos == 0:
        continue
    count[pre][pos] += 1
res = 0
for i in range(1, 10):
    for j in range(1, 10):
        res += count[i][j] * count[j][i]
print(res)

-cnt = [[0] * 10 for i in range(10)]  # (10,10)サイズの配列 -ret = 0 - - -def hoge(m): -    # return m[-1],m[0] -    return (m % 10, int(str(m)[0])) - - -for k in range(1, n + 1): -    a, b = hoge(k) -    cnt[a][b] += 1 +count = [[0] * 10 for _ in range(10)] +for i in range(1, n + 1): +    now = str(i) +    pre, pos = int(now[0]), int(now[-1]) +    if pos == 0: +        continue +    count[pre][pos] += 1 +res = 0 -        ret += cnt[i][j] * cnt[j][i] -print(ret) +        res += count[i][j] * count[j][i] +print(res)