n = int(eval(input()))

if n > 30:

    x = n // 10

    basenum = x * x + 8

    addnum = 0

    #print("{0} {1}".format(x* 10 + 1, n))

    hassame = False

    for i in range(x * 10 + 1, n+1):

        #print(i)

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

            #print(j)

            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:

                addnum += 1

                if i == j:

                    hassame=True

                #print("{0},{1}".format(i, j))

    res = basenum + addnum * 2

    if hassame:

        res-=1

    #print("n={0}, x={1}, basenum={2}, addnum={3} res ={4}".format(n,x,basenum,addnum,res))

    print(res)

elif n==1:

    print((1))

else:

    res = 0

    for i in range(1, n):

        for j in range(1, n):

            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:

                res += 1

    print(("{1}".format(n, res)))

n = int(eval(input()))

if n < 10:

    print(n)

else:

    x = n // 10

    basenum = x * x + 8

    addnum = 0

    # print("{0} {1}".format(x* 10 + 1, n))

    hassame = False

    for i in range(x * 10 + 1, n + 1):

        # print(i)

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

            # print(j)

            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:

                addnum += 1

                if i == j:

                    hassame = True

                # print("{0},{1}".format(i, j))

    res = basenum + addnum * 2

    if hassame:

        res -= 1

    # print("n={0}, x={1}, basenum={2}, addnum={3} res ={4}".format(n,x,basenum,addnum,res))

    print(res)

n = int(eval(input()))
if n > 30:
    x = n // 10
    basenum = x * x + 8
    addnum = 0
    # print("{0} {1}".format(x* 10 + 1, n))
    hassame = False
    for i in range(x * 10 + 1, n + 1):
        # print(i)
        for j in range(1, n + 1):
            # print(j)
            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
                addnum += 1
                if i == j:
                    hassame = True
                # print("{0},{1}".format(i, j))
    res = basenum + addnum * 2
    if hassame:
        res -= 1
    # print("n={0}, x={1}, basenum={2}, addnum={3} res ={4}".format(n,x,basenum,addnum,res))
    print(res)
elif n == 1:
    print((1))
else:
    res = 0
    for i in range(1, n):
        for j in range(1, n):
            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
                res += 1
    print(("{1}".format(n, res)))

n = int(eval(input()))
if n < 10:
    print(n)
else:
    x = n // 10
    basenum = x * x + 8
    addnum = 0
    # print("{0} {1}".format(x* 10 + 1, n))
    hassame = False
    for i in range(x * 10 + 1, n + 1):
        # print(i)
        for j in range(1, n + 1):
            # print(j)
            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]:
                addnum += 1
                if i == j:
                    hassame = True
                # print("{0},{1}".format(i, j))
    res = basenum + addnum * 2
    if hassame:
        res -= 1
    # print("n={0}, x={1}, basenum={2}, addnum={3} res ={4}".format(n,x,basenum,addnum,res))
    print(res)

-if n > 30: +if n < 10: +    print(n) +else: -elif n == 1: -    print((1)) -else: -    res = 0 -    for i in range(1, n): -        for j in range(1, n): -            if str(i)[0] == str(j)[-1] and str(i)[-1] == str(j)[0]: -                res += 1 -    print(("{1}".format(n, res)))