import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random

import sys

from collections import deque, defaultdict, Counter; from heapq import heappush, heappop

from itertools import permutations, combinations, product, accumulate, groupby

from bisect import bisect_left, bisect_right, insort_left, insort_right

from operator import itemgetter as ig

sys.setrecursionlimit(10 ** 7)

inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()

eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7

dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]

"""for dx, dy in dd:

        nx = j + dx; ny = i + dy

            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))

def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint

def ws(): return sys.stdin.readline().split()

def i(): return int(sys.stdin.readline())

def s(): return eval(input())

def s_list(): return list(eval(input()))

def hi(n): return [i() for _ in range(n)]

def hs(n): return [s() for _ in range(n)]#HeightString

def mi(n): return [wi() for _ in range(n)]#MatrixInt

def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid

def mip(n): return [wip() for _ in range(n)]

def ms(n): return [ws() for _ in range(n)]

def grid(n): return [s_list() for _ in range(n)]



n = i()

nx = str(n)[0]

ny = str(n)[-1]

digit = len(str(n))

is_full = [1, 11, 111, 1111, 11111]



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

    x = str(i)[0]

    y = str(i)[-1]

    if y == "0":

        continue

    #digit = len(str(i))

    if x == y:

        ans += 1

        if y < nx:

            if digit - 2 < 0:

                continue

            ans += is_full[digit - 2]

        elif y == nx:

            if digit - 3 >= 0:

                ans += is_full[digit - 3]

            for num, k in enumerate(list(str(n))[1: -1], 1):

                ans += int(k) * 10 ** (digit - 2 - num)



            if digit == 2:

                if int(x + y) <= n:

                    ans += 1

            if digit >= 3 and x <= ny:

                ans += 1



        else:

            if digit - 3 < 0:

                continue

            ans += is_full[digit - 3]

    else:

        if y < nx:

            if digit - 2 < 0:

                continue

            ans += is_full[digit - 2]

        elif y == nx:

            if digit - 3 >= 0:

                ans += is_full[digit - 3]

            for num, k in enumerate(list(str(n))[1: -1], 1):

                ans += int(k) * 10 ** (digit - 2 - num)

            if digit == 2:

                if int(x + y) <= n:

                    ans += 1

            if digit >= 3 and x <= ny:

                ans += 1

        else:

            if digit - 3 < 0:

                continue

            ans += is_full[digit - 3]



print(ans)
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random

import sys

from collections import deque, defaultdict, Counter; from heapq import heappush, heappop

from itertools import permutations, combinations, product, accumulate, groupby

from bisect import bisect_left, bisect_right, insort_left, insort_right

from operator import itemgetter as ig

sys.setrecursionlimit(10 ** 7)

inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()

eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7

dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]

"""for dx, dy in dd:

        nx = j + dx; ny = i + dy

            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))

def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint

def ws(): return sys.stdin.readline().split()

def i(): return int(sys.stdin.readline())

def s(): return eval(input())

def s_list(): return list(eval(input()))

def hi(n): return [i() for _ in range(n)]

def hs(n): return [s() for _ in range(n)]#HeightString

def mi(n): return [wi() for _ in range(n)]#MatrixInt

def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid

def mip(n): return [wip() for _ in range(n)]

def ms(n): return [ws() for _ in range(n)]

def grid(n): return [s_list() for _ in range(n)]



n = i()

nx = str(n)[0]

ny = str(n)[-1]

digit = len(str(n))

is_full = [1, 11, 111, 1111, 11111]



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

    x = str(i)[0]

    y = str(i)[-1]

    if y == "0":  # 0が先頭になるときを考えない

        continue



    if x == y:  # xとyが同じとき3などの一桁の値をとりうるので+1する

        ans += 1



    if y < nx:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより小さいとき

        if digit - 2 < 0:  # 無条件で取れる，ものが無ければcontinue

            continue

        ans += is_full[digit - 2]

    elif y == nx:

        if digit - 3 >= 0:

            ans += is_full[digit - 3]

        for num, k in enumerate(list(str(n))[1: -1], 1):  # y???xとnx???nyを比較していく

            ans += int(k) * 10 ** (digit - 2 - num)



        if digit >= 2 and x <= ny:  # 10の位をもうひとつ上げられるとき

            ans += 1

    else:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより大きいとき

        if digit - 3 < 0:  # このときは無条件に取れるis_fullの位が一段階下がる

            continue

        ans += is_full[digit - 3]



print(ans)
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig

sys.setrecursionlimit(10**7)
inf = 10**20
INF = float("INF")
ans = 0
tmp = 0
cnt = 0
ansli = []
tmpli = []
candili = []
stillset = set()
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""


def wi():
    return list(map(int, sys.stdin.readline().split()))


def wip():
    return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint


def ws():
    return sys.stdin.readline().split()


def i():
    return int(sys.stdin.readline())


def s():
    return eval(input())


def s_list():
    return list(eval(input()))


def hi(n):
    return [i() for _ in range(n)]


def hs(n):
    return [s() for _ in range(n)]  # HeightString


def mi(n):
    return [wi() for _ in range(n)]  # MatrixInt


def num_grid(n):
    return [
        [int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)
    ]  # NumberGrid


def mip(n):
    return [wip() for _ in range(n)]


def ms(n):
    return [ws() for _ in range(n)]


def grid(n):
    return [s_list() for _ in range(n)]


n = i()
nx = str(n)[0]
ny = str(n)[-1]
digit = len(str(n))
is_full = [1, 11, 111, 1111, 11111]
for i in range(1, n + 1):
    x = str(i)[0]
    y = str(i)[-1]
    if y == "0":
        continue
    # digit = len(str(i))
    if x == y:
        ans += 1
        if y < nx:
            if digit - 2 < 0:
                continue
            ans += is_full[digit - 2]
        elif y == nx:
            if digit - 3 >= 0:
                ans += is_full[digit - 3]
            for num, k in enumerate(list(str(n))[1:-1], 1):
                ans += int(k) * 10 ** (digit - 2 - num)
            if digit == 2:
                if int(x + y) <= n:
                    ans += 1
            if digit >= 3 and x <= ny:
                ans += 1
        else:
            if digit - 3 < 0:
                continue
            ans += is_full[digit - 3]
    else:
        if y < nx:
            if digit - 2 < 0:
                continue
            ans += is_full[digit - 2]
        elif y == nx:
            if digit - 3 >= 0:
                ans += is_full[digit - 3]
            for num, k in enumerate(list(str(n))[1:-1], 1):
                ans += int(k) * 10 ** (digit - 2 - num)
            if digit == 2:
                if int(x + y) <= n:
                    ans += 1
            if digit >= 3 and x <= ny:
                ans += 1
        else:
            if digit - 3 < 0:
                continue
            ans += is_full[digit - 3]
print(ans)

import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig

sys.setrecursionlimit(10**7)
inf = 10**20
INF = float("INF")
ans = 0
tmp = 0
cnt = 0
ansli = []
tmpli = []
candili = []
stillset = set()
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""


def wi():
    return list(map(int, sys.stdin.readline().split()))


def wip():
    return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint


def ws():
    return sys.stdin.readline().split()


def i():
    return int(sys.stdin.readline())


def s():
    return eval(input())


def s_list():
    return list(eval(input()))


def hi(n):
    return [i() for _ in range(n)]


def hs(n):
    return [s() for _ in range(n)]  # HeightString


def mi(n):
    return [wi() for _ in range(n)]  # MatrixInt


def num_grid(n):
    return [
        [int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)
    ]  # NumberGrid


def mip(n):
    return [wip() for _ in range(n)]


def ms(n):
    return [ws() for _ in range(n)]


def grid(n):
    return [s_list() for _ in range(n)]


n = i()
nx = str(n)[0]
ny = str(n)[-1]
digit = len(str(n))
is_full = [1, 11, 111, 1111, 11111]
for i in range(1, n + 1):
    x = str(i)[0]
    y = str(i)[-1]
    if y == "0":  # 0が先頭になるときを考えない
        continue
    if x == y:  # xとyが同じとき3などの一桁の値をとりうるので+1する
        ans += 1
    if y < nx:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより小さいとき
        if digit - 2 < 0:  # 無条件で取れる，ものが無ければcontinue
            continue
        ans += is_full[digit - 2]
    elif y == nx:
        if digit - 3 >= 0:
            ans += is_full[digit - 3]
        for num, k in enumerate(list(str(n))[1:-1], 1):  # y???xとnx???nyを比較していく
            ans += int(k) * 10 ** (digit - 2 - num)
        if digit >= 2 and x <= ny:  # 10の位をもうひとつ上げられるとき
            ans += 1
    else:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより大きいとき
        if digit - 3 < 0:  # このときは無条件に取れるis_fullの位が一段階下がる
            continue
        ans += is_full[digit - 3]
print(ans)

-    if y == "0": +    if y == "0":  # 0が先頭になるときを考えない -    # digit = len(str(i)) -    if x == y: +    if x == y:  # xとyが同じとき3などの一桁の値をとりうるので+1する -        if y < nx: -            if digit - 2 < 0: -                continue -            ans += is_full[digit - 2] -        elif y == nx: -            if digit - 3 >= 0: -                ans += is_full[digit - 3] -            for num, k in enumerate(list(str(n))[1:-1], 1): -                ans += int(k) * 10 ** (digit - 2 - num) -            if digit == 2: -                if int(x + y) <= n: -                    ans += 1 -            if digit >= 3 and x <= ny: -                ans += 1 -        else: -            if digit - 3 < 0: -                continue +    if y < nx:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより小さいとき +        if digit - 2 < 0:  # 無条件で取れる，ものが無ければcontinue +            continue +        ans += is_full[digit - 2] +    elif y == nx: +        if digit - 3 >= 0: -    else: -        if y < nx: -            if digit - 2 < 0: -                continue -            ans += is_full[digit - 2] -        elif y == nx: -            if digit - 3 >= 0: -                ans += is_full[digit - 3] -            for num, k in enumerate(list(str(n))[1:-1], 1): -                ans += int(k) * 10 ** (digit - 2 - num) -            if digit == 2: -                if int(x + y) <= n: -                    ans += 1 -            if digit >= 3 and x <= ny: -                ans += 1 -        else: -            if digit - 3 < 0: -                continue -            ans += is_full[digit - 3] +        for num, k in enumerate(list(str(n))[1:-1], 1):  # y???xとnx???nyを比較していく +            ans += int(k) * 10 ** (digit - 2 - num) +        if digit >= 2 and x <= ny:  # 10の位をもうひとつ上げられるとき +            ans += 1 +    else:  # 注目している数字の末尾，つまり考えている数字y??xの先頭の文字yがnxより大きいとき +        if digit - 3 < 0:  # このときは無条件に取れるis_fullの位が一段階下がる +            continue +        ans += is_full[digit - 3]