N = int(eval(input()))

digit = len(str(N))



ans = 0

for a in range(1, 10):

    for b in range(1, 10):

        x, y = 0, 0

        if a == b:

            if a <= N:

                x += 1

                y += 1



        if a*10+b <= N:

            x += 1



        if b*10+a <= N:

            y += 1



        if digit <= 2:

            ans += x*y

            continue



        d = 3

        while d < digit:

            x += 10**(d-2)

            y += 10**(d-2)

            d += 1



        for i in range(10**(digit-2)):

            if int(str(a)+str(i).zfill(digit-2)+str(b)) <= N:

                x += 1

            if int(str(b)+str(i).zfill(digit-2)+str(a)) <= N:

                y += 1

        ans += x*y



print(ans)

N = int(eval(input()))



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



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

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

    j = int(str(n)[-1])

    C[i][j] += 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()))
digit = len(str(N))
ans = 0
for a in range(1, 10):
    for b in range(1, 10):
        x, y = 0, 0
        if a == b:
            if a <= N:
                x += 1
                y += 1
        if a * 10 + b <= N:
            x += 1
        if b * 10 + a <= N:
            y += 1
        if digit <= 2:
            ans += x * y
            continue
        d = 3
        while d < digit:
            x += 10 ** (d - 2)
            y += 10 ** (d - 2)
            d += 1
        for i in range(10 ** (digit - 2)):
            if int(str(a) + str(i).zfill(digit - 2) + str(b)) <= N:
                x += 1
            if int(str(b) + str(i).zfill(digit - 2) + str(a)) <= N:
                y += 1
        ans += x * y
print(ans)

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

-digit = len(str(N)) +C = [[0] * 10 for i in range(10)] +for n in range(1, N + 1): +    i = int(str(n)[0]) +    j = int(str(n)[-1]) +    C[i][j] += 1 -for a in range(1, 10): -    for b in range(1, 10): -        x, y = 0, 0 -        if a == b: -            if a <= N: -                x += 1 -                y += 1 -        if a * 10 + b <= N: -            x += 1 -        if b * 10 + a <= N: -            y += 1 -        if digit <= 2: -            ans += x * y -            continue -        d = 3 -        while d < digit: -            x += 10 ** (d - 2) -            y += 10 ** (d - 2) -            d += 1 -        for i in range(10 ** (digit - 2)): -            if int(str(a) + str(i).zfill(digit - 2) + str(b)) <= N: -                x += 1 -            if int(str(b) + str(i).zfill(digit - 2) + str(a)) <= N: -                y += 1 -        ans += x * y +for i in range(1, 10): +    for j in range(1, 10): +        ans += C[i][j] * C[j][i]