### BUGGY CODE ###

n = int(input())
cnt = 0
ls = []
"""
def chk(a,b):
    if a[len(a)-1] == '0' or b[len(b)-1] == '0':
        return 0
    elif a[0] == b[len(b)-1] and a[len(a)-1] == b[0] and a == b:
        return 1
    elif a[0] == b[len(b)-1] and a[len(a)-1] == b[0]:
        return 2
    else:
        return 0
"""
ls = []
dic = {}
for i in range(1,10):
    for j in range(1,10):
        ls.append([str(i),str(j)])

for i in range(81):
    dic[i] = 0

for i in range(1,n+1):
    a = str(i)
    if a[len(a)-1] != '0':
        #print([a[0],str(i)[len(a)-1]])
        if dic[ls.index([str(i)[len(a)-1],a[0]])] == 0 and a[0] == a[len(a)-1]:
            #print(a,1)
            #print([str(i)[len(a)-1],a[0]])
            cnt += 1
        elif a[0] == a[len(a)-1]:
            #print(a,2)
            #print([str(i)[len(a)-1],a[0]])
            cnt += dic[ls.index([str(i)[len(a)-1],a[0]])] * 2 + 1
        elif dic[ls.index([str(i)[len(a)-1],a[0]])] != 0:
            #print(a)
            cnt += dic[ls.index([str(i)[len(a)-1],a[0]])]*2
        dic[ls.index([a[0],str(i)[len(a)-1]])] += 1

print(cnt)


### FIXED CODE ###

n = int(input())
cnt = 0
ls = []
"""
def chk(a,b):
    if a[len(a)-1] == '0' or b[len(b)-1] == '0':
        return 0
    elif a[0] == b[len(b)-1] and a[len(a)-1] == b[0] and a == b:
        return 1
    elif a[0] == b[len(b)-1] and a[len(a)-1] == b[0]:
        return 2
    else:
        return 0
"""
ls = []
dic = {}
for i in range(1,10):
    for j in range(1,10):
        ls.append([str(i),str(j)])

for i in range(81):
    dic[i] = 0


if n <= 50000:
    for i in range(1,n+1):
        a = str(i)
        if a[len(a)-1] != '0':
            #print([a[0],str(i)[len(a)-1]])
            if dic[ls.index([str(i)[len(a)-1],a[0]])] == 0 and a[0] == a[len(a)-1]:
                #print(a,1)
                #print([str(i)[len(a)-1],a[0]])
                cnt += 1
            elif a[0] == a[len(a)-1]:
                #print(a,2)
                #print([str(i)[len(a)-1],a[0]])
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])] * 2 + 1
            elif dic[ls.index([str(i)[len(a)-1],a[0]])] != 0:
                #print(a)
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])]*2
            dic[ls.index([a[0],str(i)[len(a)-1]])] += 1

elif n <= 100000:
    dic = {0: 1112, 1: 1111, 2: 1111, 3: 1111, 4: 1111, 5: 1111, 6: 1111, 7: 1111, 8: 1111, 9: 1111, 10: 1112, 11: 1111, 12: 1111, 13: 1111, 14: 1111, 15: 1111, 16: 1111, 17: 1111, 18: 1111, 19: 1111, 20: 1112, 21: 1111, 22: 1111, 23: 1111, 24: 1111, 25: 1111, 26: 1111, 27: 1111, 28: 1111, 29: 1111, 30: 1112, 31: 1111, 32: 1111, 33: 1111, 34: 1111, 35: 1111, 36: 111, 37: 111, 38: 111, 39: 111, 40: 112, 41: 111, 42: 111, 43: 111, 44: 111, 45: 111, 46: 111, 47: 111, 48: 111, 49: 111, 50: 112, 51: 111, 52: 111, 53: 111, 54: 111, 55: 111, 56: 111, 57: 111, 58: 111, 59: 111, 60: 112, 61: 111, 62: 111, 63: 111, 64: 111, 65: 111, 66: 111, 67: 111, 68: 111, 69: 111, 70: 112, 71: 111, 72: 111, 73: 111, 74: 111, 75: 111, 76: 111, 77: 111, 78: 111, 79: 111, 80: 112}
    cnt = 25000008
    for i in range(50001,n+1):
        a = str(i)
        if a[len(a)-1] != '0':
            #print([a[0],str(i)[len(a)-1]])
            if dic[ls.index([str(i)[len(a)-1],a[0]])] == 0 and a[0] == a[len(a)-1]:
                #print(a,1)
                #print([str(i)[len(a)-1],a[0]])
                cnt += 1
            elif a[0] == a[len(a)-1]:
                #print(a,2)
                #print([str(i)[len(a)-1],a[0]])
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])] * 2 + 1
            elif dic[ls.index([str(i)[len(a)-1],a[0]])] != 0:
                #print(a)
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])]*2
            dic[ls.index([a[0],str(i)[len(a)-1]])] += 1
elif n <= 150000:
    dic = {0: 1112, 1: 1111, 2: 1111, 3: 1111, 4: 1111, 5: 1111, 6: 1111, 7: 1111, 8: 1111, 9: 1111, 10: 1112, 11: 1111, 12: 1111, 13: 1111, 14: 1111, 15: 1111, 16: 1111, 17: 1111, 18: 1111, 19: 1111, 20: 1112, 21: 1111, 22: 1111, 23: 1111, 24: 1111, 25: 1111, 26: 1111, 27: 1111, 28: 1111, 29: 1111, 30: 1112, 31: 1111, 32: 1111, 33: 1111, 34: 1111, 35: 1111, 36: 1111, 37: 1111, 38: 1111, 39: 1111, 40: 1112, 41: 1111, 42: 1111, 43: 1111, 44: 1111, 45: 1111, 46: 1111, 47: 1111, 48: 1111, 49: 1111, 50: 1112, 51: 1111, 52: 1111, 53: 1111, 54: 1111, 55: 1111, 56: 1111, 57: 1111, 58: 1111, 59: 1111, 60: 1112, 61: 1111, 62: 1111, 63: 1111, 64: 1111, 65: 1111, 66: 1111, 67: 1111, 68: 1111, 69: 1111, 70: 1112, 71: 1111, 72: 1111, 73: 1111, 74: 1111, 75: 1111, 76: 1111, 77: 1111, 78: 1111, 79: 1111, 80: 1112}
    cnt = 100000008
    for i in range(100001,n+1):
        a = str(i)
        if a[len(a)-1] != '0':
            #print([a[0],str(i)[len(a)-1]])
            if dic[ls.index([str(i)[len(a)-1],a[0]])] == 0 and a[0] == a[len(a)-1]:
                #print(a,1)
                #print([str(i)[len(a)-1],a[0]])
                cnt += 1
            elif a[0] == a[len(a)-1]:
                #print(a,2)
                #print([str(i)[len(a)-1],a[0]])
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])] * 2 + 1
            elif dic[ls.index([str(i)[len(a)-1],a[0]])] != 0:
                #print(a)
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])]*2
            dic[ls.index([a[0],str(i)[len(a)-1]])] += 1
else:
    dic = {0: 6112, 1: 6111, 2: 6111, 3: 6111, 4: 6111, 5: 6111, 6: 6111, 7: 6111, 8: 6111, 9: 1111, 10: 1112, 11: 1111, 12: 1111, 13: 1111, 14: 1111, 15: 1111, 16: 1111, 17: 1111, 18: 1111, 19: 1111, 20: 1112, 21: 1111, 22: 1111, 23: 1111, 24: 1111, 25: 1111, 26: 1111, 27: 1111, 28: 1111, 29: 1111, 30: 1112, 31: 1111, 32: 1111, 33: 1111, 34: 1111, 35: 1111, 36: 1111, 37: 1111, 38: 1111, 39: 1111, 40: 1112, 41: 1111, 42: 1111, 43: 1111, 44: 1111, 45: 1111, 46: 1111, 47: 1111, 48: 1111, 49: 1111, 50: 1112, 51: 1111, 52: 1111, 53: 1111, 54: 1111, 55: 1111, 56: 1111, 57: 1111, 58: 1111, 59: 1111, 60: 1112, 61: 1111, 62: 1111, 63: 1111, 64: 1111, 65: 1111, 66: 1111, 67: 1111, 68: 1111, 69: 1111, 70: 1112, 71: 1111, 72: 1111, 73: 1111, 74: 1111, 75: 1111, 76: 1111, 77: 1111, 78: 1111, 79: 1111, 80: 1112}
    cnt = 225000008
    for i in range(150001,n+1):
        a = str(i)
        if a[len(a)-1] != '0':
            #print([a[0],str(i)[len(a)-1]])
            if dic[ls.index([str(i)[len(a)-1],a[0]])] == 0 and a[0] == a[len(a)-1]:
                #print(a,1)
                #print([str(i)[len(a)-1],a[0]])
                cnt += 1
            elif a[0] == a[len(a)-1]:
                #print(a,2)
                #print([str(i)[len(a)-1],a[0]])
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])] * 2 + 1
            elif dic[ls.index([str(i)[len(a)-1],a[0]])] != 0:
                #print(a)
                cnt += dic[ls.index([str(i)[len(a)-1],a[0]])]*2
            dic[ls.index([a[0],str(i)[len(a)-1]])] += 1


print(cnt)