from itertools import product





def solve(string):

    l = len(string)

    *ns, = list(map(int, string))

    n = int(string)

    c = [0] + [10**i for i in range(6)]

    t = sum(c[:l - 1])

    t = [[t] * 10 for _ in range(10)]

    if l > 1:

        for i in range(10):

            t[i][i] += 1

    for i in range(1, ns[0]):

        for j in range(1, 10):

            t[i][j] += c[l - 1]

    for i in range(ns[0] * 10**(l - 1), n + 1):

        i = str(i)

        t[int(i[0])][int(i[-1])] += 1

    return str(sum(t[i][j] * t[j][i] for i, j in product(list(range(1, 10)), repeat=2)))





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

from itertools import product





def solve(string):

    d = len(string)

    if d == 1:

        return string

    s0, ss, sn = int(string[0]), int(string[1:-1] or 0), int(string[-1])

    t = [[0] * 10] + [[int("1" * (d - 2) or 0)] * 10 for _ in range(9)]

    for i in range(1, 10):

        t[i][i] += 1

    for i, j in product(list(range(1, s0)), list(range(10))):

        t[i][j] += 10**(d - 2)

    for j in range(sn + 1):

        t[s0][j] += ss + 1

    for j in range(sn + 1, 10):

        t[s0][j] += ss

    return str(sum(t[i][j] * t[j][i] for i, j in product(list(range(1, 10)), repeat=2)))





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

from itertools import product


def solve(string):
    l = len(string)
    (*ns,) = list(map(int, string))
    n = int(string)
    c = [0] + [10**i for i in range(6)]
    t = sum(c[: l - 1])
    t = [[t] * 10 for _ in range(10)]
    if l > 1:
        for i in range(10):
            t[i][i] += 1
    for i in range(1, ns[0]):
        for j in range(1, 10):
            t[i][j] += c[l - 1]
    for i in range(ns[0] * 10 ** (l - 1), n + 1):
        i = str(i)
        t[int(i[0])][int(i[-1])] += 1
    return str(sum(t[i][j] * t[j][i] for i, j in product(list(range(1, 10)), repeat=2)))


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

from itertools import product


def solve(string):
    d = len(string)
    if d == 1:
        return string
    s0, ss, sn = int(string[0]), int(string[1:-1] or 0), int(string[-1])
    t = [[0] * 10] + [[int("1" * (d - 2) or 0)] * 10 for _ in range(9)]
    for i in range(1, 10):
        t[i][i] += 1
    for i, j in product(list(range(1, s0)), list(range(10))):
        t[i][j] += 10 ** (d - 2)
    for j in range(sn + 1):
        t[s0][j] += ss + 1
    for j in range(sn + 1, 10):
        t[s0][j] += ss
    return str(sum(t[i][j] * t[j][i] for i, j in product(list(range(1, 10)), repeat=2)))


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

-    l = len(string) -    (*ns,) = list(map(int, string)) -    n = int(string) -    c = [0] + [10**i for i in range(6)] -    t = sum(c[: l - 1]) -    t = [[t] * 10 for _ in range(10)] -    if l > 1: -        for i in range(10): -            t[i][i] += 1 -    for i in range(1, ns[0]): -        for j in range(1, 10): -            t[i][j] += c[l - 1] -    for i in range(ns[0] * 10 ** (l - 1), n + 1): -        i = str(i) -        t[int(i[0])][int(i[-1])] += 1 +    d = len(string) +    if d == 1: +        return string +    s0, ss, sn = int(string[0]), int(string[1:-1] or 0), int(string[-1]) +    t = [[0] * 10] + [[int("1" * (d - 2) or 0)] * 10 for _ in range(9)] +    for i in range(1, 10): +        t[i][i] += 1 +    for i, j in product(list(range(1, s0)), list(range(10))): +        t[i][j] += 10 ** (d - 2) +    for j in range(sn + 1): +        t[s0][j] += ss + 1 +    for j in range(sn + 1, 10): +        t[s0][j] += ss