import sys

input = sys.stdin.readline



def main():

    N = int(eval(input()))

    dic = {}

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

        tmp = str(i)

        s, e = int(tmp[0]), int(tmp[-1])

        if (s, e) in dic:

            dic[(s, e)] += 1

        else:

            dic[(s, e)] = 1

    

    ans = 0

    for (i, j), count in list(dic.items()):

        tmp = 0

        if i == j:

            tmp = count**2

        else:

            if (j, i) in dic:

                tmp = count * dic[(j, i)]

        ans += tmp

        # print(i, j, count)

    print(ans)





if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline



def main():

    N = int(eval(input()))

    dic = {}

    for i in range(10):

        for j in range(10):

            dic[(i, j)] = 0

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

        tmp = str(i)

        s, e = int(tmp[0]), int(tmp[-1])

        dic[(s, e)] += 1

    ans = 0

    for i in range(10):

        for j in range(10):

            ans += dic[(i, j)] * dic[(j, i)]

    print(ans)



if __name__ == "__main__":

    main()
import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    dic = {}
    for i in range(1, N + 1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        if (s, e) in dic:
            dic[(s, e)] += 1
        else:
            dic[(s, e)] = 1
    ans = 0
    for (i, j), count in list(dic.items()):
        tmp = 0
        if i == j:
            tmp = count**2
        else:
            if (j, i) in dic:
                tmp = count * dic[(j, i)]
        ans += tmp
        # print(i, j, count)
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    dic = {}
    for i in range(10):
        for j in range(10):
            dic[(i, j)] = 0
    for i in range(1, N + 1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        dic[(s, e)] += 1
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += dic[(i, j)] * dic[(j, i)]
    print(ans)


if __name__ == "__main__":
    main()

+    for i in range(10): +        for j in range(10): +            dic[(i, j)] = 0 -        if (s, e) in dic: -            dic[(s, e)] += 1 -        else: -            dic[(s, e)] = 1 +        dic[(s, e)] += 1 -    for (i, j), count in list(dic.items()): -        tmp = 0 -        if i == j: -            tmp = count**2 -        else: -            if (j, i) in dic: -                tmp = count * dic[(j, i)] -        ans += tmp -        # print(i, j, count) +    for i in range(10): +        for j in range(10): +            ans += dic[(i, j)] * dic[(j, i)]