def main():

    N = int(eval(input()))

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

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

        s = str(n)

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

    ans = 0

    for i in range(1, 10):

        for j in range(1, 10):

            # if c[i][j]*c[j][i]:

            #     print(i, j, c[i][j]*c[j][i])

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

    print(ans)

    # print(*c, sep="\n")





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

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

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

        s = str(num)

        px = int(s[0])

        sf = int(s[-1])

        C[px][sf] += 1

    ans = 0

    for i in range(1, 10):

        for j in range(1, 10):

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

    print(ans)





if __name__ == '__main__':

    main()

def main():
    N = int(eval(input()))
    c = [[0] * 10 for _ in range(10)]
    for n in range(1, N + 1):
        s = str(n)
        c[int(s[0])][int(s[-1])] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            # if c[i][j]*c[j][i]:
            #     print(i, j, c[i][j]*c[j][i])
            ans += c[i][j] * c[j][i]
    print(ans)
    # print(*c, sep="\n")


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    C = [[0] * 10 for _ in range(10)]
    for num in range(1, N + 1):
        s = str(num)
        px = int(s[0])
        sf = int(s[-1])
        C[px][sf] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += C[i][j] * C[j][i]
    print(ans)


if __name__ == "__main__":
    main()

-    c = [[0] * 10 for _ in range(10)] -    for n in range(1, N + 1): -        s = str(n) -        c[int(s[0])][int(s[-1])] += 1 +    C = [[0] * 10 for _ in range(10)] +    for num in range(1, N + 1): +        s = str(num) +        px = int(s[0]) +        sf = int(s[-1]) +        C[px][sf] += 1 -            # if c[i][j]*c[j][i]: -            #     print(i, j, c[i][j]*c[j][i]) -            ans += c[i][j] * c[j][i] +            ans += C[i][j] * C[j][i] -    # print(*c, sep="\n")