import sys

input = sys.stdin.readline

from operator import itemgetter

sys.setrecursionlimit(10000000)

INF = 10**30



def keta(n):

    return len(str(n))



def make(n, l, r):

    ans = 0

    sn = str(n)

    for i in range(5):

        if keta(n) > 2+i:

            ans += 10 ** i

        elif keta(n) == 2 + i:

            if sn[0] > str(l):

                ans += 10 ** i

            elif sn[0] == str(l):

                if sn[-1] < r:

                    ans += int(sn[1:-1])

                else:

                    if sn[1:-1] == '':

                        ans += 1

                    else:

                        ans += int(sn[1:-1]) + 1

            else:

                pass

        else:

            pass

    if l == r:

        ans += 1

    return ans



def main():

    n = int(input().strip())

    ans = 0

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

        p = make(n, str(i)[-1], str(i)[0])

        if i % 10 == 0:

            continue

        # if i < 10:

        #     p += 1

        # print("i ,p: ", i, p)

        ans += p

    print(ans)

if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline

from operator import itemgetter

sys.setrecursionlimit(10000000)

INF = 10**30

from collections import defaultdict



def main():

    n = int(input().strip())

    d = defaultdict(int)

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

        ds = str(i)

        d[(ds[0], ds[-1])] += 1

    ans = 0

    for i in range(1, 10):

        for j in range(1, 10):

            si = str(i)

            sj = str(j)

            ans += d[(si, sj)] * d[(sj, si)]

    print(ans)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline
from operator import itemgetter

sys.setrecursionlimit(10000000)
INF = 10**30


def keta(n):
    return len(str(n))


def make(n, l, r):
    ans = 0
    sn = str(n)
    for i in range(5):
        if keta(n) > 2 + i:
            ans += 10**i
        elif keta(n) == 2 + i:
            if sn[0] > str(l):
                ans += 10**i
            elif sn[0] == str(l):
                if sn[-1] < r:
                    ans += int(sn[1:-1])
                else:
                    if sn[1:-1] == "":
                        ans += 1
                    else:
                        ans += int(sn[1:-1]) + 1
            else:
                pass
        else:
            pass
    if l == r:
        ans += 1
    return ans


def main():
    n = int(input().strip())
    ans = 0
    for i in range(1, n + 1):
        p = make(n, str(i)[-1], str(i)[0])
        if i % 10 == 0:
            continue
        # if i < 10:
        #     p += 1
        # print("i ,p: ", i, p)
        ans += p
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
from operator import itemgetter

sys.setrecursionlimit(10000000)
INF = 10**30
from collections import defaultdict


def main():
    n = int(input().strip())
    d = defaultdict(int)
    for i in range(1, n + 1):
        ds = str(i)
        d[(ds[0], ds[-1])] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            si = str(i)
            sj = str(j)
            ans += d[(si, sj)] * d[(sj, si)]
    print(ans)


if __name__ == "__main__":
    main()

- - -def keta(n): -    return len(str(n)) - - -def make(n, l, r): -    ans = 0 -    sn = str(n) -    for i in range(5): -        if keta(n) > 2 + i: -            ans += 10**i -        elif keta(n) == 2 + i: -            if sn[0] > str(l): -                ans += 10**i -            elif sn[0] == str(l): -                if sn[-1] < r: -                    ans += int(sn[1:-1]) -                else: -                    if sn[1:-1] == "": -                        ans += 1 -                    else: -                        ans += int(sn[1:-1]) + 1 -            else: -                pass -        else: -            pass -    if l == r: -        ans += 1 -    return ans +from collections import defaultdict +    d = defaultdict(int) +    for i in range(1, n + 1): +        ds = str(i) +        d[(ds[0], ds[-1])] += 1 -    for i in range(1, n + 1): -        p = make(n, str(i)[-1], str(i)[0]) -        if i % 10 == 0: -            continue -        # if i < 10: -        #     p += 1 -        # print("i ,p: ", i, p) -        ans += p +    for i in range(1, 10): +        for j in range(1, 10): +            si = str(i) +            sj = str(j) +            ans += d[(si, sj)] * d[(sj, si)]