CodeEff/ECCO huggingface dataset:
# Original solution
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = 0

    d = Counter()
    for i in range(N+1):
        l = len(str(i))
        a = i // 10 ** (l-1)
        b = i % 10
        if a != 0 and b != 0:
            d[(a, b)] += 1

    ans = 0
    for a, b in product(range(1, 10), repeat=2):
        ans += d[(a, b)] * d[(b, a)]
    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


# Optimized solution
from collections import Counter
N = int(eval(input()))

c = Counter()
for i in range(1, N+1):
  a = str(i)
  c[(a[0], a[-1])] += 1

ans = 0
for k, v in list(c.items()):
  ans += v*c[(k[1], k[0])]
print(ans)
# Original solution
import sys
import collections
import bisect


def main():
    n = int(eval(input()))
    a = [str(i + 1)[0] + str(i + 1)[-1] for i in range(n)]
    b = [str(i + 1)[-1] + str(i + 1)[0] for i in range(n)]
    ac, bc = collections.Counter(a), collections.Counter(b)
    print((sum(ac[i] * bc[i] for i in list(ac.keys()))))


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import collections
import bisect


def main():
    n = int(eval(input()))
    ac, bc = collections.Counter([str(i + 1)[0] + str(i + 1)[-1] for i in range(
        n)]), collections.Counter([str(i + 1)[-1] + str(i + 1)[0] for i in range(n)])
    print((sum(ac[i] * bc[i] for i in list(ac.keys()))))


if __name__ == '__main__':
    main()
# Original solution
def main():
    N = int(eval(input()))
    # ある数値nについて、n[0]..n[-1]とすると
    # 1~n-1の中のある数値mに対して、n[0]==m[-1]&&n[-1]==m[0]となるようなmがいくつ存在するか調べたい
    # n:1...3 -> m:3...1かつlen(n)>len(m)を満たすもの*2
    # n:3...1 -> m:1...3かつlen(n)>=len(m)を満たすもの*2
    # n:1...1 -> m:1...1かつlen(n)>=len(m)を満たすもの*2
    # 下のパターンで、n[0]==n[-1]のときだけ(n,n)が重複するので-1する
    if N<=9:
        print(N)
    else:
        count = 9
        for n in range(10,N+1):
            n = str(n)
            nlen = len(n)
            if n[-1] == '0':
                continue
            if n[0]<n[-1]:
                tmp = int('1'*(nlen-2)) if nlen>2 else 0
                count += tmp*2
            elif n[0]>n[-1]:
                tmp = int('1'*(nlen-1)) if nlen>2 else 1
                count += tmp*2
            else:
                # 2桁以上(10~)と比較
                tmp = int('1'*(nlen-2))+int(n[1:-1])+1 if nlen>2 else 1
                count += tmp*2-1
                # 1桁(1~9)と比較
                count += 2
        print(count)

main()


# Optimized solution
def main():
    N = int(eval(input()))
    # cnt[a][b] := 先頭がa,末尾がqである数の個数
    cnt = [[0]*10 for i in range(10)]
    for i in range(1,N+1):
        s = str(i)
        cnt[int(s[0])][int(s[-1])] += 1
    ans = 0
    for a in range(10):
        for b in range(10):
            ans += cnt[a][b]*cnt[b][a]
    print(ans)

main()
# Original solution
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def keta(n):
    return len(str(n))

def make(n, l, r):
    ans = 0
    sn = str(n)
    for i in range(5):
        if keta(n) > 2+i:
            ans += 10 ** i
        elif keta(n) == 2 + i:
            if sn[0] > str(l):
                ans += 10 ** i
            elif sn[0] == str(l):
                if sn[-1] < r:
                    ans += int(sn[1:-1])
                else:
                    if sn[1:-1] == '':
                        ans += 1
                    else:
                        ans += int(sn[1:-1]) + 1
            else:
                pass
        else:
            pass
    if l == r:
        ans += 1
    return ans

def main():
    n = int(input().strip())
    ans = 0
    for i in range(1, n+1):
        p = make(n, str(i)[-1], str(i)[0])
        if i % 10 == 0:
            continue
        # if i < 10:
        #     p += 1
        # print("i ,p: ", i, p)
        ans += p
    print(ans)
if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import defaultdict

def main():
    n = int(input().strip())
    d = defaultdict(int)
    for i in range(1, n+1):
        ds = str(i)
        d[(ds[0], ds[-1])] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            si = str(i)
            sj = str(j)
            ans += d[(si, sj)] * d[(sj, si)]
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
book = [[0] * 9 for i in range(9)]

ans = 0

for i in range(1, n+1) :
    reverse = 0
    tmp = i
    time = 0
    flag = False
    end = -1
    while(tmp!=0) :
        remind = tmp % 10
        if time == 0 :
            if remind == 0 :
                flag = True
                break
            pre = remind
        tmp = tmp // 10
        time += 1
    if flag == True :
        continue
    if remind != 0 :
        book[remind-1][pre-1] += 1

for i in range(9) :
    for j in range(i, 9) :
        if i == j :
            ans += book[i][j] * book[j][i]
            #print('=', i, j, book[i][j] * book[j][i])
            continue
        if book[i][j] != 0 and book[j][i] != 0 :
            ans += book[i][j] * book[j][i] * 2
            #print('!', i, j, book[i][j] * book[j][i] * 2)

#for i in range(9) :
#    print(book[i])

print(ans)


# Optimized solution
n = int(eval(input()))
book = [[0] * 9 for i in range(9)]

ans = 0

for i in range(1, n+1) :
    pre = int(str(i)[0])
    end = int(str(i)[-1])

    if end != 0 :
        book[pre-1][end-1] += 1

for i in range(9) :
    for j in range(i, 9) :
        if i == j :
            ans += book[i][j] * book[j][i]
            #print('=', i, j, book[i][j] * book[j][i])
            continue
        if book[i][j] != 0 and book[j][i] != 0 :
            ans += book[i][j] * book[j][i] * 2
            #print('!', i, j, book[i][j] * book[j][i] * 2)

#for i in range(9) :
#    print(book[i])

print(ans)
# Original solution
N = int(eval(input()))
N_list = [str(i) for i in range(1, N + 1)]
nums = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

count = 0
for i in nums:
    for j in nums:
        cij, cji = 0, 0
        for k in N_list:
            if k[0] == i and k[-1] == j:
                cij += 1
            if k[0] == j and k[-1] == i:
                cji += 1
        count += cij * cji

print(count)

# Optimized solution
N = int(eval(input()))

Cij = [0] * 100
for i in range(1, N + 1):
    Cij[int(str(i)[0] + str(i)[-1])] += 1

count = 0
for i in range(10):
    for j in range(10):
        count += Cij[i * 10 + j] * Cij[j * 10 + i]

print(count)
# Original solution
from itertools import product
N = int(eval(input()))

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10**(b_o-2)
            else:      
                for p in product(list(range(10)),repeat=n_o-2):
                    ans_temp=int(a_e+''.join(map(str,p))+a_s)
                    if ans_temp > N:
                        break
                    ans+=1 
                    B_temp.append(ans_temp)
    #                 print(B_temp)

        else:
            break
        
    return ans

for a in range(1,N+1):
#     print('====',a)
    ans_=get_ans(a)
    ans+=ans_
print(ans)

# Optimized solution
N = int(eval(input()))

C=[[0]*10 for _ in range(10)]

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)
# Original solution
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n=int(eval(input()))
	
	ans1=0
	ans2=0
	
	for i in range(1,n+1):
		a=int(str(i)[0])
		b=i%10
		
		if b==0:
			continue
		k=len(str(i))
		if k==1:
			ans2+=1
		elif a>b:
			ans1+=(10**(k-1)-1)//9
		elif a<b:
			ans1+=(10**(k-2)-1)//9
		else:
			ans1+=(10**(k-2)-1)//9+1+(int(str(i)[1:])-a)//10
			ans2+=1
	print((ans1*2+ans2))
	
	
	
	
	


if __name__ == "__main__":
	main()


# Optimized solution
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	li=[[0]*10 for i in range(10)]
	n=int(eval(input()))
	for i in range(1,n+1):
		i=str(i)
		li[int(i[0])][int(i[-1])]+=1

	ans=0

	for i in range(1,10):
		for j in range(1,10):
			ans+=li[i][j]*li[j][i]

	print(ans)
















if __name__ == "__main__":
	main()
# Original solution
import sys
input = sys.stdin.readline

def main():
    N = int(eval(input()))
    dic = {}
    for i in range(1, N+1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        if (s, e) in dic:
            dic[(s, e)] += 1
        else:
            dic[(s, e)] = 1
    
    ans = 0
    for (i, j), count in list(dic.items()):
        tmp = 0
        if i == j:
            tmp = count**2
        else:
            if (j, i) in dic:
                tmp = count * dic[(j, i)]
        ans += tmp
        # print(i, j, count)
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
import sys
input = sys.stdin.readline

def main():
    N = int(eval(input()))
    dic = {}
    for i in range(10):
        for j in range(10):
            dic[(i, j)] = 0
    for i in range(1, N+1):
        tmp = str(i)
        s, e = int(tmp[0]), int(tmp[-1])
        dic[(s, e)] += 1
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += dic[(i, j)] * dic[(j, i)]
    print(ans)

if __name__ == "__main__":
    main()
# Original solution
N=int(eval(input()))

c_list = []
for i in range(10):
    temp_list = []
    for j in range(10):
        temp_count = 0
        for n in range(1, N+1):
            if n%10==j and n//(10**(len(str(n))-1) )==i:
                temp_count += 1
        temp_list.append(temp_count)
    c_list.append(temp_list)
sum=0
for i in range(10):
    for j in range(10):
        sum += c_list[i][j]*c_list[j][i]
print(sum)


# Optimized solution
N=int(eval(input()))

N_digit = len(str(N))
if N_digit==1:
    print(N)
    exit()

N_head = N//(10**(N_digit-1))
N_tail = N%10

count = 0
for A in range(1, N+1):
    A_digit = len(str(A))
    A_head  = A//(10**(A_digit-1))
    A_tail  = A%10

    if A_tail==0:
        continue

    if A_head==A_tail:
        count += 1

    for digit in range(2, N_digit+1):
        if digit==N_digit:
            if A_tail < N_head:
                count += 10**(digit-2)
            elif A_tail == N_head:
                if A_head <= N_tail:
                    count += N//10-N_head*(10**(N_digit-2))+1
                else:
                    count += N//10-N_head*(10**(N_digit-2))
            else:
                pass
        else:
            count += 10**(digit-2)
print(count)
# Original solution
n = int(eval(input()))

ans = 0
numbers = [[0] * 10 for _ in range(10)]
for i in range(1, n+1):
    ss = str(i)
    numbers[int(ss[0])][int(ss[-1])] += 1

for j in range(1, n+1):
    ss = str(j)
    ans += numbers[int(ss[-1])][int(ss[0])]

print(ans)



# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))

    res = 0
    numbers = [[0] * 10 for _ in range(10)]
    for i in range(1, n + 1):
        ss = str(i)
        numbers[int(ss[0])][int(ss[-1])] += 1

    for j in range(1, 10):
        for k in range(1, 10):
            res += numbers[j][k] * numbers[k][j]

    print(res)


if __name__ == '__main__':
    resolve()
# Original solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))

    cnt = [[0] * 10 for _ in range(10)]
    for i in range(1, n + 1):
        head = int(str(i)[0])
        tale = int(str(i)[-1])
        cnt[head][tale] += 1
        
    res = 0
    for i in range(1, n + 1):
        head = int(str(i)[0])
        tale = int(str(i)[-1])
        res += cnt[tale][head]

    print(res)


if __name__ == '__main__':
    resolve()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))

    cnt = [[0] * 10 for _ in range(10)]
    for i in range(1, n + 1):
        i = str(i)
        head = int(i[0])
        foot = int(i[-1])
        cnt[head][foot] += 1

    res = 0
    for i in range(1, n + 1):
        i = str(i)
        head = int(i[0])
        foot = int(i[-1])
        res += cnt[foot][head]
    print(res)


if __name__ == '__main__':
    resolve()
# Original solution
S=eval(input())
TT=[[0]*10 for _ in range(10)]
N=int(S)

for i in range(1,N+1):
    ii=str(i)
    a=int(ii[0])
    b=int(ii[-1])
    TT[a][b]+=1
    
ans=0
for i in range(10):
    for j in range(10):
        ans+=TT[i][j]*TT[j][i]
        
print(ans)

# Optimized solution
import sys
input = sys.stdin.readline

def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    
    def ht(x):
        t=x%10
        string=str(x)
        h=int(string[0])
        return (h,t)
        
    cnt=[[0]*10 for _ in range(10)]
    
    for i in range(1,N+1):
        h,t=ht(i)
        cnt[h][t]+=1
        
    ans=0
    for i in range(10):
        for j in range(10):
            a=cnt[i][j]
            b=cnt[j][i]
            ans+=a*b
            
    print(ans)
        

main()
# Original solution
N= int(eval(input()))
lead_N = int(str(N)[0]) 
end_N = int(str(N)[len(str(N)) - 1])
ans = 0
#print(str(100)[len(str(100)) - 1])
for i in range(1, N + 1):
  lead = int(str(i)[0])
  end = int(str(i)[len(str(i)) - 1])
  # 一桁
  if lead == end:
    ans += 1
  #2桁以上ループ lead + 中間 + end　
  for j in range((len(str(N)) - 2) + 1):
    if end == 0:
      #末尾が0
      continue
    elif end > lead_N and j == (len(str(N)) - 2) :
      #生成する整数がNに収まらない場合
      continue
    elif end == lead_N and j == (len(str(N)) - 2):
      #生成する整数の一部がNに収まらない場合
      #中間の数字
      if len(str(N)) >= 3:
        ans += int(str(N)[1:len(str(N)) - 1])

      if lead <= end_N:
        ans += 1
      #print("b")
      pass
    else:
      #何も気にしないときは組み合わせの分だけたす
      ans += 10 ** j

print(ans)

# Optimized solution
N= int(eval(input()))
lead_N = int(str(N)[0]) 
end_N = int(str(N)[-1])
ans = 0
for i in range(1, N + 1):
  lead = int(str(i)[0])
  end = int(str(i)[-1])
  # 一桁
  if lead == end:
    ans += 1
  #2桁以上ループ lead + 中間 + end　
  for j in range((len(str(N)) - 2) + 1):
    if end == 0 or (end > lead_N and j == (len(str(N)) - 2)):
      #末尾が0　または　生成する整数がNに収まらない場合
      continue
    elif end == lead_N and j == (len(str(N)) - 2):
      #生成する整数の一部がNに収まらない場合
      #中間の数字
      if len(str(N)) >= 3:
        ans += int(str(N)[1:-1])
      if lead <= end_N:
        ans += 1
    else:
      #何も気にしないときは組み合わせの分だけたす
      ans += 10 ** j

print(ans)
# Original solution
def II(): return int(eval(input()))
N=II()
tbl=[0]*101
for i in range(1,N+1):
  i=str(i)
  tbl[int(str(i[0]+i[-1]))]+=1
ans=0
for i in range(1,N+1):
  i=str(i)
  ans+=tbl[int(str(i[-1]+i[0]))]
print(ans)
      

# Optimized solution
def II(): return int(eval(input()))
N=II()
tbl=[0]*101
for i in range(1,N+1):
  i=str(i)
  tbl[int(i[0]+i[-1])]+=1
ans=0
for i in range(1,N+1):
  i=str(i)
  ans+=tbl[int(i[-1]+i[0])]
print(ans)
# Original solution
def II(): return int(eval(input()))
N=II()
tbl=[0]*101
for i in range(1,N+1):
  i=str(i)
  tbl[int(i[0]+i[-1])]+=1
ans=0
for i in range(1,N+1):
  i=str(i)
  ans+=tbl[int(i[-1]+i[0])]
print(ans)
      

# Optimized solution
def II(): return int(eval(input()))
N=II()
def solve(n):
  tbl=[0]*100
  ans=0
  for i in range(1,n+1):
    i=str(i)
    tbl[int(i[0]+i[-1])]+=1
  for i in range(1,n+1):
    i=str(i)
    ans+=tbl[int(i[-1]+i[0])]
  return ans
a=solve(N)
print(a)
# Original solution
from collections import defaultdict
N = int(eval(input()))

def fl(x):
    f = 0
    l = x % 10
    while x != 0:
        f = x
        x = x // 10
    return (f, l)

d = defaultdict(int)

for i in range(1, N+1):
    d[fl(i)] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += d[(i, j)] * d[(j, i)]

print(ans)

# Optimized solution
from collections import defaultdict

N = int(eval(input()))

def pair(n):
    l = n % 10
    while n != 0:
        f = n
        n = n // 10
    return (f, l)

d = defaultdict(int)

for i in range(1, N + 1):
    d[pair(i)] += 1

ans = 0
for key, value in list(d.items()):
    tmp1 = value
    l, f = key
    if (f, l) in list(d.keys()):
        tmp2 = d[(f, l)]   
        ans += tmp1 * tmp2
print(ans)
# Original solution
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def check(min_, max_, x):
  if max_ <= x:
    return 10**max(0, len(str(min_))-2)
  elif min_ <= x:
    ret = max(1, int(str(x)[1:-1]) if len(str(x)) > 2 else 1)
    if int(str(min_)[-1]) <= int(str(x)[-1]):
      ret += 1
    return ret
  else:
    return 0


def main():
  N = int(eval(input()))

  if len(str(N)) == 1:
    print(N)
    return
  sum_ = 0
  for l in range(1, 10):
    for r in range(l, 10):
      temp = sum_
      min_ = int(str(l) + '0'*(len(str(N))-2) + str(r))
      max_ = int(str(l) + '9'*(len(str(N))-2) + str(r))
      A = check(min_, max_, N)
      # max_ = int(str(l) + '9'*(len(str(N))-3) + str(r))
      for gap in range(len(str(N))-2):
        A += (10**gap)

      min_ = int(str(r) + '0'*(len(str(N))-2) + str(l))
      max_ = int(str(r) + '9'*(len(str(N))-2) + str(l))
      B = check(min_, max_, N)
      for gap in range(len(str(N))-2):
        B += (10**gap)

      if l == r:
        A += 1
        B += 1
        sum_ += A*B
      else:
        sum_ += 2*A*B
      # print(l, r, sum_ - temp)

  print(sum_)


if(__name__ == '__main__'):
  main()


# Optimized solution
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def check(min_, max_, x):
  if max_ <= x:
    # return 10**max(0, len(str(min_))-2)
    return int((max_ - min_)/10) + 1
  elif min_ <= x:
    # ret = max(1, int(str(x)[1:-1]) if len(str(x)) > 2 else 1)
    # if int(str(min_)[-1]) <= int(str(x)[-1]):
    #   ret += 1
    # return ret
    return int((x - min_)/10) + 1
  else:
    return 0


def main():
  N = int(eval(input()))

  if len(str(N)) == 1:
    print(N)
    return
  sum_ = 0
  for l in range(1, 10):
    for r in range(l, 10):
      temp = sum_
      min_ = int(str(l) + '0'*(len(str(N))-2) + str(r))
      max_ = int(str(l) + '9'*(len(str(N))-2) + str(r))
      A = check(min_, max_, N)
      # max_ = int(str(l) + '9'*(len(str(N))-3) + str(r))
      for gap in range(len(str(N))-2):
        A += (10**gap)

      min_ = int(str(r) + '0'*(len(str(N))-2) + str(l))
      max_ = int(str(r) + '9'*(len(str(N))-2) + str(l))
      B = check(min_, max_, N)
      for gap in range(len(str(N))-2):
        B += (10**gap)

      if l == r:
        A += 1
        B += 1
        sum_ += A*B
      else:
        sum_ += 2*A*B
      # print(l, r, sum_ - temp)

  print(sum_)


if(__name__ == '__main__'):
  main()
# Original solution
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def check(min_, max_, x):
  if max_ <= x:
    # return 10**max(0, len(str(min_))-2)
    return int((max_ - min_)/10) + 1
  elif min_ <= x:
    # ret = max(1, int(str(x)[1:-1]) if len(str(x)) > 2 else 1)
    # if int(str(min_)[-1]) <= int(str(x)[-1]):
    #   ret += 1
    # return ret
    return int((x - min_)/10) + 1
  else:
    return 0


def main():
  N = int(eval(input()))

  if len(str(N)) == 1:
    print(N)
    return
  sum_ = 0
  for l in range(1, 10):
    for r in range(l, 10):
      temp = sum_
      min_ = int(str(l) + '0'*(len(str(N))-2) + str(r))
      max_ = int(str(l) + '9'*(len(str(N))-2) + str(r))
      A = check(min_, max_, N)
      # max_ = int(str(l) + '9'*(len(str(N))-3) + str(r))
      for gap in range(len(str(N))-2):
        A += (10**gap)

      min_ = int(str(r) + '0'*(len(str(N))-2) + str(l))
      max_ = int(str(r) + '9'*(len(str(N))-2) + str(l))
      B = check(min_, max_, N)
      for gap in range(len(str(N))-2):
        B += (10**gap)

      if l == r:
        A += 1
        B += 1
        sum_ += A*B
      else:
        sum_ += 2*A*B
      # print(l, r, sum_ - temp)

  print(sum_)


if(__name__ == '__main__'):
  main()


# Optimized solution
from sys import stdin
input = stdin.readline


def check(min_, max_, x):
  if x < min_:
    return 0
  else:
    return int((min(max_, x) - min_)/10) + 1


def main():
  N = int(eval(input()))

  if len(str(N)) == 1:
    print(N)
    return
  sum_ = 0
  for l in range(1, 10):
    for r in range(l, 10):
      temp = sum_
      min_ = int(str(l) + '0'*(len(str(N))-2) + str(r))
      max_ = int(str(l) + '9'*(len(str(N))-2) + str(r))
      A = check(min_, max_, N)
      # max_ = int(str(l) + '9'*(len(str(N))-3) + str(r))
      for gap in range(len(str(N))-2):
        A += (10**gap)

      min_ = int(str(r) + '0'*(len(str(N))-2) + str(l))
      max_ = int(str(r) + '9'*(len(str(N))-2) + str(l))
      B = check(min_, max_, N)
      for gap in range(len(str(N))-2):
        B += (10**gap)

      if l == r:
        A += 1
        B += 1
        sum_ += A*B
      else:
        sum_ += 2*A*B
      # print(l, r, sum_ - temp)

  print(sum_)


if(__name__ == '__main__'):
  main()
# Original solution
n=int(eval(input()))
count=[[0 for i in range(10)] for j in range(9)]
ans=0
for i in range(1,n+1):
    num=list(str(i))
    l,r=eval(num[0]),eval(num[-1])
    #print(str(l)+"  "+str(r))
    #print(l+r)
    count[l-1][r]+=1
#print(count)
for i in range(1,10):
    for j in range(1,10):
        if i==j:
            continue
        ans+=(count[i-1][j])*(count[j-1][i])
for i in range(1,10):
    ans+=(count[i-1][i]**2)
print(ans)

# Optimized solution
n=int(eval(input()))
count=[[0 for i in range(10)] for j in range(9)]
ans=0
num=1
zero=0
for i in range(1,n+1):
    if (10**(zero+1))<=num:
        zero+=1
    a=i//10
    r=i-a*10
    l=i//(10**zero)
    count[l-1][r]+=1
    num+=1
#print(count)
for i in range(1,10):
    for j in range(1,10):
        if i==j:
            continue
        ans+=(count[i-1][j])*(count[j-1][i])
for i in range(1,10):
    ans+=(count[i-1][i]**2)
print(ans)