N=int(eval(input()))

C=[[0]*9  for i in range(9)]

count=0



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

   if str(n)[-1]!="0":

      left=int(str(n)[0])-1

      right=int(str(n)[-1])-1

      C[left][right]+=1

      

for i in range(1,10):

   for j in range(1,10):

      count+=C[i-1][j-1]*C[j-1][i-1]



print(count)
from sys import stdin

def main():

    #入力

    readline=stdin.readline

    N=int(readline())

    d=dict()

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

        i=str(i)

        head=i[0]

        tail=i[-1]

        if tail=="0":

            continue

        if (head,tail) not in d:

            d[(head,tail)]=1

        else:

            d[(head,tail)]+=1



    ans=0

    s=set()

    for k in list(d.keys()):

        m,l=k[0],k[1]

        if (m,l) in s:

            continue

        if (l,m) in d:

            ans+=d[(m,l)]*d[(l,m)]

            if (m,l)!=(l,m):

                ans+=d[(m,l)]*d[(l,m)]

        s.add((m,l))

        s.add((l,m))



    print(ans)



if __name__=="__main__":

    main()
N = int(eval(input()))
C = [[0] * 9 for i in range(9)]
count = 0
for n in range(1, N + 1):
    if str(n)[-1] != "0":
        left = int(str(n)[0]) - 1
        right = int(str(n)[-1]) - 1
        C[left][right] += 1
for i in range(1, 10):
    for j in range(1, 10):
        count += C[i - 1][j - 1] * C[j - 1][i - 1]
print(count)

from sys import stdin


def main():
    # 入力
    readline = stdin.readline
    N = int(readline())
    d = dict()
    for i in range(1, N + 1):
        i = str(i)
        head = i[0]
        tail = i[-1]
        if tail == "0":
            continue
        if (head, tail) not in d:
            d[(head, tail)] = 1
        else:
            d[(head, tail)] += 1
    ans = 0
    s = set()
    for k in list(d.keys()):
        m, l = k[0], k[1]
        if (m, l) in s:
            continue
        if (l, m) in d:
            ans += d[(m, l)] * d[(l, m)]
            if (m, l) != (l, m):
                ans += d[(m, l)] * d[(l, m)]
        s.add((m, l))
        s.add((l, m))
    print(ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -C = [[0] * 9 for i in range(9)] -count = 0 -for n in range(1, N + 1): -    if str(n)[-1] != "0": -        left = int(str(n)[0]) - 1 -        right = int(str(n)[-1]) - 1 -        C[left][right] += 1 -for i in range(1, 10): -    for j in range(1, 10): -        count += C[i - 1][j - 1] * C[j - 1][i - 1] -print(count) +from sys import stdin + + +def main(): +    # 入力 +    readline = stdin.readline +    N = int(readline()) +    d = dict() +    for i in range(1, N + 1): +        i = str(i) +        head = i[0] +        tail = i[-1] +        if tail == "0": +            continue +        if (head, tail) not in d: +            d[(head, tail)] = 1 +        else: +            d[(head, tail)] += 1 +    ans = 0 +    s = set() +    for k in list(d.keys()): +        m, l = k[0], k[1] +        if (m, l) in s: +            continue +        if (l, m) in d: +            ans += d[(m, l)] * d[(l, m)] +            if (m, l) != (l, m): +                ans += d[(m, l)] * d[(l, m)] +        s.add((m, l)) +        s.add((l, m)) +    print(ans) + + +if __name__ == "__main__": +    main()