import sys



def solve():

    N = int(eval(input()))

    D = dict()

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

        front = i % 10

        back = i

        while back >= 10: back //= 10

        if front > 0:

            if (front, back) in D: D[(front, back)] += 1

            else: D[(front, back)] = 1

    Ans = 0

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

        back = i % 10

        if back > 0:

            front = i

            while front >= 10: front //= 10

            if (front, back) in D: Ans += D[(front, back)]

    print(Ans)



    return 0



if __name__ == "__main__":

    solve()
import sys



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    dictType = dict()

    for i in range(1, 10):

        for j in range(1, 10): dictType[(i, j)] = 0

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

        bottom = i % 10

        if bottom == 0: continue

        top = i

        while top >= 10: top //= 10

        dictType[(top, bottom)] += 1



    ans = 0

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

        bottom = i % 10

        if bottom == 0: continue

        top = i

        while top >= 10: top //= 10

        ans += dictType[(bottom, top)]

    print(ans)



    return 0



if __name__ == "__main__":

    solve()
import sys


def solve():
    N = int(eval(input()))
    D = dict()
    for i in range(1, N + 1):
        front = i % 10
        back = i
        while back >= 10:
            back //= 10
        if front > 0:
            if (front, back) in D:
                D[(front, back)] += 1
            else:
                D[(front, back)] = 1
    Ans = 0
    for i in range(1, N + 1):
        back = i % 10
        if back > 0:
            front = i
            while front >= 10:
                front //= 10
            if (front, back) in D:
                Ans += D[(front, back)]
    print(Ans)
    return 0


if __name__ == "__main__":
    solve()

import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    dictType = dict()
    for i in range(1, 10):
        for j in range(1, 10):
            dictType[(i, j)] = 0
    for i in range(1, N + 1):
        bottom = i % 10
        if bottom == 0:
            continue
        top = i
        while top >= 10:
            top //= 10
        dictType[(top, bottom)] += 1
    ans = 0
    for i in range(1, N + 1):
        bottom = i % 10
        if bottom == 0:
            continue
        top = i
        while top >= 10:
            top //= 10
        ans += dictType[(bottom, top)]
    print(ans)
    return 0


if __name__ == "__main__":
    solve()

+    input = sys.stdin.readline -    D = dict() +    dictType = dict() +    for i in range(1, 10): +        for j in range(1, 10): +            dictType[(i, j)] = 0 -        front = i % 10 -        back = i -        while back >= 10: -            back //= 10 -        if front > 0: -            if (front, back) in D: -                D[(front, back)] += 1 -            else: -                D[(front, back)] = 1 -    Ans = 0 +        bottom = i % 10 +        if bottom == 0: +            continue +        top = i +        while top >= 10: +            top //= 10 +        dictType[(top, bottom)] += 1 +    ans = 0 -        back = i % 10 -        if back > 0: -            front = i -            while front >= 10: -                front //= 10 -            if (front, back) in D: -                Ans += D[(front, back)] -    print(Ans) +        bottom = i % 10 +        if bottom == 0: +            continue +        top = i +        while top >= 10: +            top //= 10 +        ans += dictType[(bottom, top)] +    print(ans)