import collections

def main():



    N = int(eval(input()))



    d = collections.defaultdict(int)

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

        s = str(i)

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



    ans = 0

    for a in d:

        b = (a[1], a[0])

        if b in d:

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

    return ans







if __name__ == '__main__':

    print((main()))
def main():



    N = int(eval(input()))



    d = dict()

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

        u = int(str(i)[0])

        v = int(str(i)[-1])

        d[(u, v)] = d.get((u, v), 0) + 1



    ans = 0

    for u, v in d:

        if (v, u) in d:

            ans += d[(u, v)] * d[(v, u)]

    return ans





if __name__ == '__main__':

    print((main()))

import collections


def main():
    N = int(eval(input()))
    d = collections.defaultdict(int)
    for i in range(1, N + 1):
        s = str(i)
        d[(s[0], s[-1])] += 1
    ans = 0
    for a in d:
        b = (a[1], a[0])
        if b in d:
            ans += d[a] * d[b]
    return ans


if __name__ == "__main__":
    print((main()))

def main():
    N = int(eval(input()))
    d = dict()
    for i in range(1, N + 1):
        u = int(str(i)[0])
        v = int(str(i)[-1])
        d[(u, v)] = d.get((u, v), 0) + 1
    ans = 0
    for u, v in d:
        if (v, u) in d:
            ans += d[(u, v)] * d[(v, u)]
    return ans


if __name__ == "__main__":
    print((main()))

-import collections - - -    d = collections.defaultdict(int) +    d = dict() -        s = str(i) -        d[(s[0], s[-1])] += 1 +        u = int(str(i)[0]) +        v = int(str(i)[-1]) +        d[(u, v)] = d.get((u, v), 0) + 1 -    for a in d: -        b = (a[1], a[0]) -        if b in d: -            ans += d[a] * d[b] +    for u, v in d: +        if (v, u) in d: +            ans += d[(u, v)] * d[(v, u)]