def main():

    N = int(eval(input()))

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

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

        tmp = str(i)

        top = int(tmp[0])

        end = int(tmp[-1])

        cnt[top][end] += 1

    ans = 0

    for a in range(10):

        for b in range(10):

            for c in range(10):

                for d in range(10):

                    if a == d and b == c:

                        ans += cnt[a][b] * cnt[c][d]



    print(ans)







if __name__ == "__main__":

    main()
def main():

    N = int(eval(input()))

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

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

        tmp = str(i)

        left = int(tmp[0])

        right = int(tmp[-1])

        if left == 0 or right == 0:

            continue

        dp[left][right] += 1



    ans = 0

    for i in range(10):

        for j in range(10):

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



    print(ans)





if __name__ == "__main__":

    main()
def main():
    N = int(eval(input()))
    cnt = [[0] * 10 for _ in range(10)]
    for i in range(1, N + 1):
        tmp = str(i)
        top = int(tmp[0])
        end = int(tmp[-1])
        cnt[top][end] += 1
    ans = 0
    for a in range(10):
        for b in range(10):
            for c in range(10):
                for d in range(10):
                    if a == d and b == c:
                        ans += cnt[a][b] * cnt[c][d]
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    dp = [[0] * 10 for _ in range(10)]
    for i in range(1, N + 1):
        tmp = str(i)
        left = int(tmp[0])
        right = int(tmp[-1])
        if left == 0 or right == 0:
            continue
        dp[left][right] += 1
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += dp[i][j] * dp[j][i]
    print(ans)


if __name__ == "__main__":
    main()

-    cnt = [[0] * 10 for _ in range(10)] +    dp = [[0] * 10 for _ in range(10)] -        top = int(tmp[0]) -        end = int(tmp[-1]) -        cnt[top][end] += 1 +        left = int(tmp[0]) +        right = int(tmp[-1]) +        if left == 0 or right == 0: +            continue +        dp[left][right] += 1 -    for a in range(10): -        for b in range(10): -            for c in range(10): -                for d in range(10): -                    if a == d and b == c: -                        ans += cnt[a][b] * cnt[c][d] +    for i in range(10): +        for j in range(10): +            ans += dp[i][j] * dp[j][i]