n=int(eval(input()))

v=[0]*100

ans=0

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

    x=int(str(i)[0])

    y=int(str(i)[-1])

    v[x*10+y]+=1



for i in range(len(v)):

    x=int(str(i)[0])

    y=int(str(i)[-1])

    ans+=v[i]*v[10*y+x]

print(ans)
n=int(eval(input()))

x=[0]*101

ans=0

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

    v=str(i)

    w=int(v[0]+v[-1])

    x[w]+=1



for i in range(101):

    if x[i]!=0:

        v=str(i)

        w=int(v[-1]+v[0])

        ans+=x[i]*x[w]

print(ans)
n = int(eval(input()))
v = [0] * 100
ans = 0
for i in range(1, n + 1):
    x = int(str(i)[0])
    y = int(str(i)[-1])
    v[x * 10 + y] += 1
for i in range(len(v)):
    x = int(str(i)[0])
    y = int(str(i)[-1])
    ans += v[i] * v[10 * y + x]
print(ans)

n = int(eval(input()))
x = [0] * 101
ans = 0
for i in range(1, n + 1):
    v = str(i)
    w = int(v[0] + v[-1])
    x[w] += 1
for i in range(101):
    if x[i] != 0:
        v = str(i)
        w = int(v[-1] + v[0])
        ans += x[i] * x[w]
print(ans)

-v = [0] * 100 +x = [0] * 101 -    x = int(str(i)[0]) -    y = int(str(i)[-1]) -    v[x * 10 + y] += 1 -for i in range(len(v)): -    x = int(str(i)[0]) -    y = int(str(i)[-1]) -    ans += v[i] * v[10 * y + x] +    v = str(i) +    w = int(v[0] + v[-1]) +    x[w] += 1 +for i in range(101): +    if x[i] != 0: +        v = str(i) +        w = int(v[-1] + v[0]) +        ans += x[i] * x[w]