def solve():

    N = int(eval(input()))



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

    for x in range(1, 10):

        for y in range(1, 10):

            num = 0

            for d in range(1, 5):

                for i in range(10**d):

                    j = x*10**(d+1) + i*10 + y

                    if 1 <= j <= N:

                        num += 1

                    else:

                        break

            j = x*10 + y

            if 1 <= j <= N:

                num += 1

            if x == y:

                j = x

                if 1 <= j <= N:

                    num += 1

            numss[x][y] = num



    ans = 0

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

        ss = str(A)

        ans += numss[int(ss[-1])][int(ss[0])]



    print(ans)





solve()

def solve():

    strN = eval(input())

    N = int(strN)



    maxD = len(strN)



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

    for x in range(1, 10):

        for y in range(1, 10):

            num = 0

            for d in range(1, maxD-2):

                num += 10**d

            if maxD-2 > 0:

                if x < int(strN[0]):

                    num += 10**(maxD-2)

                elif x == int(strN[0]):

                    num += int(strN[1:-1]) + 1

                    if y > int(strN[-1]):

                        num -= 1

            j = x*10 + y

            if 1 <= j <= N:

                num += 1

            if x == y:

                j = x

                if 1 <= j <= N:

                    num += 1

            numss[x][y] = num



    ans = 0

    for i in range(1, 10):

        for j in range(1, 10):

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



    print(ans)





solve()

def solve():
    N = int(eval(input()))
    numss = [[0] * (10) for _ in range(10)]
    for x in range(1, 10):
        for y in range(1, 10):
            num = 0
            for d in range(1, 5):
                for i in range(10**d):
                    j = x * 10 ** (d + 1) + i * 10 + y
                    if 1 <= j <= N:
                        num += 1
                    else:
                        break
            j = x * 10 + y
            if 1 <= j <= N:
                num += 1
            if x == y:
                j = x
                if 1 <= j <= N:
                    num += 1
            numss[x][y] = num
    ans = 0
    for A in range(1, N + 1):
        ss = str(A)
        ans += numss[int(ss[-1])][int(ss[0])]
    print(ans)


solve()

def solve():
    strN = eval(input())
    N = int(strN)
    maxD = len(strN)
    numss = [[0] * (10) for _ in range(10)]
    for x in range(1, 10):
        for y in range(1, 10):
            num = 0
            for d in range(1, maxD - 2):
                num += 10**d
            if maxD - 2 > 0:
                if x < int(strN[0]):
                    num += 10 ** (maxD - 2)
                elif x == int(strN[0]):
                    num += int(strN[1:-1]) + 1
                    if y > int(strN[-1]):
                        num -= 1
            j = x * 10 + y
            if 1 <= j <= N:
                num += 1
            if x == y:
                j = x
                if 1 <= j <= N:
                    num += 1
            numss[x][y] = num
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += numss[i][j] * numss[j][i]
    print(ans)


solve()

-    N = int(eval(input())) +    strN = eval(input()) +    N = int(strN) +    maxD = len(strN) -            for d in range(1, 5): -                for i in range(10**d): -                    j = x * 10 ** (d + 1) + i * 10 + y -                    if 1 <= j <= N: -                        num += 1 -                    else: -                        break +            for d in range(1, maxD - 2): +                num += 10**d +            if maxD - 2 > 0: +                if x < int(strN[0]): +                    num += 10 ** (maxD - 2) +                elif x == int(strN[0]): +                    num += int(strN[1:-1]) + 1 +                    if y > int(strN[-1]): +                        num -= 1 -    for A in range(1, N + 1): -        ss = str(A) -        ans += numss[int(ss[-1])][int(ss[0])] +    for i in range(1, 10): +        for j in range(1, 10): +            ans += numss[i][j] * numss[j][i]