



N = int(eval(input()))



if len(str(N))<4:

    ans = 0

    

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

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

            if str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]:

                ans += 1

    

    print(ans)

    exit()

    

L = len(str(N))

n = int(str(N)[1:])

ans = 0

F = int(str(N)[0])

L2 = int(str(N)[-1])

S = str(N)

M = int(S[1:len(S)-1])



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

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

    l = int(str(i)[-1])



    if f==0 or l==0:

        continue

    

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

        

        if k==1 and f!=l:

            continue

        

        if k==1:

            ans += 1

            continue

        

        if k<L:

            ans += 10**(k-2)

        else:

            if F<l:

                continue

                

            if l<F:

                ans += 10**(k-2)

            else:

                if len(S)<=2:

                    continue

                

                ans += M

                

                if L2>=f:

                    ans += 1



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

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



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

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

    l = int(str(i)[-1])

    cnt[f][l] += 1



ans = 0



for i in range(1, 10):

    for j in range(1, 10):

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



print(ans)
N = int(eval(input()))
if len(str(N)) < 4:
    ans = 0
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
                ans += 1
    print(ans)
    exit()
L = len(str(N))
n = int(str(N)[1:])
ans = 0
F = int(str(N)[0])
L2 = int(str(N)[-1])
S = str(N)
M = int(S[1 : len(S) - 1])
for i in range(1, N + 1):
    f = int(str(i)[0])
    l = int(str(i)[-1])
    if f == 0 or l == 0:
        continue
    for k in range(1, L + 1):
        if k == 1 and f != l:
            continue
        if k == 1:
            ans += 1
            continue
        if k < L:
            ans += 10 ** (k - 2)
        else:
            if F < l:
                continue
            if l < F:
                ans += 10 ** (k - 2)
            else:
                if len(S) <= 2:
                    continue
                ans += M
                if L2 >= f:
                    ans += 1
print(ans)

N = int(eval(input()))
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    f = int(str(i)[0])
    l = int(str(i)[-1])
    cnt[f][l] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

-if len(str(N)) < 4: -    ans = 0 -    for i in range(1, N + 1): -        for j in range(1, N + 1): -            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]: -                ans += 1 -    print(ans) -    exit() -L = len(str(N)) -n = int(str(N)[1:]) -ans = 0 -F = int(str(N)[0]) -L2 = int(str(N)[-1]) -S = str(N) -M = int(S[1 : len(S) - 1]) +cnt = [[0] * 10 for _ in range(10)] -    if f == 0 or l == 0: -        continue -    for k in range(1, L + 1): -        if k == 1 and f != l: -            continue -        if k == 1: -            ans += 1 -            continue -        if k < L: -            ans += 10 ** (k - 2) -        else: -            if F < l: -                continue -            if l < F: -                ans += 10 ** (k - 2) -            else: -                if len(S) <= 2: -                    continue -                ans += M -                if L2 >= f: -                    ans += 1 +    cnt[f][l] += 1 +ans = 0 +for i in range(1, 10): +    for j in range(1, 10): +        ans += cnt[i][j] * cnt[j][i]