import sys

from collections import deque

from heapq import heapify, heappop, heappush

from itertools import combinations, permutations

from bisect import bisect, bisect_left



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    strN = str(N)

    maxDig = len(strN)

    count = 0

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

        a = str(i)

        low = int(a[-1])

        if low == 0: continue

        high = int(a[0])

        if low == high: count += 1 #一番上位と下位の桁の数字が同じ

        digb = 2

        while digb < maxDig:

            count += 10 ** (digb - 2)

            digb += 1

        if N >= 10:

            if low > int(strN[0]): continue

            elif low < int(strN[0]): count += 10 ** (digb - 2)

            elif N >= 10:

                DP = [[0, 0] for _ in range(maxDig)]

                DP[0][0] = 1

                for j in range(1, maxDig - 1):

                    DP[j][0] = 1

                    DP[j][1] = DP[j-1][1] * 10 + DP[j-1][0] * (int(strN[j]))



                count += DP[maxDig - 2][1] 

                #print(i, DP)

                if int(strN[maxDig - 1]) >= high: count += 1



    print(count)

        

        



    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
from collections import deque
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from bisect import bisect, bisect_left


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    strN = str(N)
    maxDig = len(strN)
    count = 0
    for i in range(1, N + 1):
        a = str(i)
        low = int(a[-1])
        if low == 0:
            continue
        high = int(a[0])
        if low == high:
            count += 1  # 一番上位と下位の桁の数字が同じ
        digb = 2
        while digb < maxDig:
            count += 10 ** (digb - 2)
            digb += 1
        if N >= 10:
            if low > int(strN[0]):
                continue
            elif low < int(strN[0]):
                count += 10 ** (digb - 2)
            elif N >= 10:
                DP = [[0, 0] for _ in range(maxDig)]
                DP[0][0] = 1
                for j in range(1, maxDig - 1):
                    DP[j][0] = 1
                    DP[j][1] = DP[j - 1][1] * 10 + DP[j - 1][0] * (int(strN[j]))
                count += DP[maxDig - 2][1]
                # print(i, DP)
                if int(strN[maxDig - 1]) >= high:
                    count += 1
    print(count)
    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()

-from collections import deque -from heapq import heapify, heappop, heappush -from itertools import combinations, permutations -from bisect import bisect, bisect_left -    input = sys.stdin.readline -    strN = str(N) -    maxDig = len(strN) -    count = 0 +    D = dict() -        a = str(i) -        low = int(a[-1]) -        if low == 0: -            continue -        high = int(a[0]) -        if low == high: -            count += 1  # 一番上位と下位の桁の数字が同じ -        digb = 2 -        while digb < maxDig: -            count += 10 ** (digb - 2) -            digb += 1 -        if N >= 10: -            if low > int(strN[0]): -                continue -            elif low < int(strN[0]): -                count += 10 ** (digb - 2) -            elif N >= 10: -                DP = [[0, 0] for _ in range(maxDig)] -                DP[0][0] = 1 -                for j in range(1, maxDig - 1): -                    DP[j][0] = 1 -                    DP[j][1] = DP[j - 1][1] * 10 + DP[j - 1][0] * (int(strN[j])) -                count += DP[maxDig - 2][1] -                # print(i, DP) -                if int(strN[maxDig - 1]) >= high: -                    count += 1 -    print(count) +        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)