from functools import lru_cache

import sys



sys.setrecursionlimit(10 ** 7)





@lru_cache(maxsize=None)

def check(l, r, n, k=1):

    t = l + '0' * k + r

    e = l + '9' * k + r



    if int(e) <= n:

        return pow(10, k) + check(l, r, n, k + 1)



    if int(t) <= n < int(e):

        x = int(str(n)[1:-1])

        if int(str(n)[-1]) < int(r):

            x -= 1

        return x + 1



    if n < int(t):

        return 0





def main():

    n = int(eval(input()))



    ret = 0

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

        if x % 10 == 0:

            continue

        s = str(x)

        t = s[-1] + s[0]

        if s[0] == s[-1]:

            ret += 1

        if int(t) <= n:

            ret += 1

        ret += check(s[-1], s[0], n, k=1)



    print(ret)





if __name__ == '__main__':

    main()

# 解説放送



def main():

    from collections import defaultdict



    n = int(eval(input()))



    d = defaultdict(int)

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

        if x % 10 == 0:

            continue



        tail = x % 10

        head = 0

        while x:

            head = x

            x //= 10



        d[head, tail] += 1



    ret = 0

    for (head, tail), cnt in tuple(d.items()):

        # RuntimeError: dictionary changed size during iteration

        # defaultdictの未定義(?)のkeyにアクセスするせいで、REになる

        # d.items()をtuple化して回避

        ret += d[head, tail] * d[tail, head]

        # (head,tail)の出現数を辞書で管理する

        # (head,tail)*(tail,head)の組み合わせがある



    print(ret)





if __name__ == '__main__':

    main()

from functools import lru_cache
import sys

sys.setrecursionlimit(10**7)


@lru_cache(maxsize=None)
def check(l, r, n, k=1):
    t = l + "0" * k + r
    e = l + "9" * k + r
    if int(e) <= n:
        return pow(10, k) + check(l, r, n, k + 1)
    if int(t) <= n < int(e):
        x = int(str(n)[1:-1])
        if int(str(n)[-1]) < int(r):
            x -= 1
        return x + 1
    if n < int(t):
        return 0


def main():
    n = int(eval(input()))
    ret = 0
    for x in range(1, n + 1):
        if x % 10 == 0:
            continue
        s = str(x)
        t = s[-1] + s[0]
        if s[0] == s[-1]:
            ret += 1
        if int(t) <= n:
            ret += 1
        ret += check(s[-1], s[0], n, k=1)
    print(ret)


if __name__ == "__main__":
    main()

# 解説放送
def main():
    from collections import defaultdict

    n = int(eval(input()))
    d = defaultdict(int)
    for x in range(1, n + 1):
        if x % 10 == 0:
            continue
        tail = x % 10
        head = 0
        while x:
            head = x
            x //= 10
        d[head, tail] += 1
    ret = 0
    for (head, tail), cnt in tuple(d.items()):
        # RuntimeError: dictionary changed size during iteration
        # defaultdictの未定義(?)のkeyにアクセスするせいで、REになる
        # d.items()をtuple化して回避
        ret += d[head, tail] * d[tail, head]
        # (head,tail)の出現数を辞書で管理する
        # (head,tail)*(tail,head)の組み合わせがある
    print(ret)


if __name__ == "__main__":
    main()

-from functools import lru_cache -import sys +# 解説放送 +def main(): +    from collections import defaultdict -sys.setrecursionlimit(10**7) - - -@lru_cache(maxsize=None) -def check(l, r, n, k=1): -    t = l + "0" * k + r -    e = l + "9" * k + r -    if int(e) <= n: -        return pow(10, k) + check(l, r, n, k + 1) -    if int(t) <= n < int(e): -        x = int(str(n)[1:-1]) -        if int(str(n)[-1]) < int(r): -            x -= 1 -        return x + 1 -    if n < int(t): -        return 0 - - -def main(): -    ret = 0 +    d = defaultdict(int) -        s = str(x) -        t = s[-1] + s[0] -        if s[0] == s[-1]: -            ret += 1 -        if int(t) <= n: -            ret += 1 -        ret += check(s[-1], s[0], n, k=1) +        tail = x % 10 +        head = 0 +        while x: +            head = x +            x //= 10 +        d[head, tail] += 1 +    ret = 0 +    for (head, tail), cnt in tuple(d.items()): +        # RuntimeError: dictionary changed size during iteration +        # defaultdictの未定義(?)のkeyにアクセスするせいで、REになる +        # d.items()をtuple化して回避 +        ret += d[head, tail] * d[tail, head] +        # (head,tail)の出現数を辞書で管理する +        # (head,tail)*(tail,head)の組み合わせがある