Given is a positive integer N.

Find the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition:
 - When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.

-----Constraints-----
 - 1 \leq N \leq 2 \times 10^5
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the answer.

-----Sample Input-----
25

-----Sample Output-----
17

The following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21), (21,12), (22,2), and (22,22).

Difficulty: MEDIUM

Solutions:
n = int(input())
l = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	st = str(i)
	start = int(st[0])
	end = int(st[-1])
	l[start][end] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += l[i][j] * l[j][i]
print(ans)


N = int(input())
cnt = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
	cnt[int(str(n)[0])][int(str(n)[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += cnt[i][j] * cnt[j][i]
print(ans)


n = int(input())
c = [[0] * 10 for i in range(10)]
for a in range(1, n + 1):
	a = str(a)
	c[int(a[-1])][int(a[0])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += c[i][j] * c[j][i]
print(ans)


N = int(input())
grp = [[0] * 10 for i in range(10)]
for x in range(N + 1):
	grp[int(str(x)[0])][int(str(x)[-1])] += 1
result = 0
for i in range(1, 10):
	for j in range(1, 10):
		result += grp[i][j] * grp[j][i]
print(result)


N = int(input())
ans = 0
lst = [0] * 100
for i in range(1, N + 1):
	A = str(i)
	(a, b) = (A[0], A[-1])
	if b == '0':
		pass
	else:
		lst[int(b + a)] += 1
for i in range(1, N + 1):
	A = str(i)
	(a, b) = (A[0], A[-1])
	c = int(a + b)
	ans += lst[c]
print(ans)


n = int(input())
ct = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	ct[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += ct[i][j] * ct[j][i]
print(ans)


def solve():
	table = [[0] * 10 for _ in range(10)]
	for i in range(N + 1):
		s = list(map(int, str(i)))
		table[s[0]][s[-1]] += 1
	return sum((table[i][j] * table[j][i] for i in range(1, 10) for j in range(1, 10)))
N = int(input())
print(solve())


N = int(input())
keep = [[0 for i in range(10)] for j in range(10)]
ans = 0
for i in range(1, N + 1):
	first = int(str(i)[0])
	end = int(str(i)[-1])
	keep[first - 1][end - 1] += 1
for i in range(9):
	for j in range(9):
		ans += keep[i][j] * keep[j][i]
print(ans)


n = int(input())
l = [[0] * 10 for i in range(10)]
for i in range(1, min(10, n + 1), 1):
	l[i][i] += 1
if len(str(n)) >= 2:
	for k in range(2, len(str(n)), 1):
		for i in range(1, 10, 1):
			for j in range(1, 10, 1):
				l[i][j] += 10 ** (k - 2)
	for i in range(1, int(str(n)[0]), 1):
		for j in range(1, 10, 1):
			l[i][j] += 10 ** (len(str(n)) - 2)
	if len(str(n)) >= 3:
		for j in range(1, 10, 1):
			if j <= int(str(n)[-1]):
				l[int(str(n)[0])][j] += int(str(n)[1:-1]) + 1
			else:
				l[int(str(n)[0])][j] += int(str(n)[1:-1])
	else:
		for j in range(1, 10, 1):
			if j <= int(str(n)[-1]):
				l[int(str(n)[0])][j] += 1
t = 0
for i in range(1, 10, 1):
	for j in range(1, 10, 1):
		t += l[i][j] * l[j][i]
print(t)


n = int(input())
l = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
	l[int(str(i)[0])][i % 10] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += l[i][j] * l[j][i]
print(ans)


def main():
	import sys
	from collections import defaultdict

	def input():
		return sys.stdin.readline().rstrip()
	n = int(input())
	nd = defaultdict(int)
	for i in range(1, n + 1):
		tmp = str(i)
		(h, t) = (int(tmp[0]), int(tmp[-1]))
		nd[h, t] += 1
	ans = 0
	for i in range(1, 10):
		for j in range(1, 10):
			ans += nd[i, j] * nd[j, i]
	print(ans)

def __starting_point():
	main()
__starting_point()


import sys
import collections
import bisect

def main():
	n = int(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()))))

def __starting_point():
	main()
__starting_point()


memo = [[0] * 10 for i in range(10)]

def kazu(start_num, end_num):
	nonlocal memo
	if memo[start_num][end_num] > 0:
		return memo[start_num][end_num]
	else:
		ans = 0
		if start_num == end_num:
			if start_num <= n:
				ans += 1
		if start_num * 10 + end_num <= n:
			ans += 1
		for i in range(10):
			if start_num * 100 + i * 10 + end_num <= n:
				ans += 1
			else:
				break
		for i in range(100):
			if start_num * 1000 + i * 10 + end_num <= n:
				ans += 1
			else:
				break
		for i in range(1000):
			if start_num * 10000 + i * 10 + end_num <= n:
				ans += 1
			else:
				break
		for i in range(10000):
			if start_num * 100000 + i * 10 + end_num <= n:
				ans += 1
			else:
				break
		memo[start_num][end_num] = ans
		return ans
n = int(input())
str_n = str(n)
kotae = 0
for a in range(1, n + 1):
	if a % 10 != 0:
		str_a = str(a)
		kotae += kazu(int(str_a[-1]), int(str_a[0]))
print(kotae)


n = int(input())
li = [0] * 100
for i in range(n + 1):
	li[int(str(i)[0] + str(i)[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += li[int(str(i) + str(j))] * li[int(str(j) + str(i))]
print(ans)


N = int(input())
m = 0
x = [[0] * 9 for i in range(9)]
for i in range(1, N + 1):
	if i % 10 == 0:
		continue
	b = int(str(i)[0])
	g = int(i % 10)
	x[b - 1][g - 1] += 1
ans = 0
for i in range(9):
	for j in range(9):
		ans += x[i][j] * x[j][i]
print(ans)


import sys
readline = sys.stdin.readline
N = int(readline())
from collections import defaultdict
dic = defaultdict(int)
for i in range(1, N + 1):
	s = str(i)
	dic[int(s[0]), int(s[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += dic[i, j] * dic[j, i]
print(ans)


import numpy as np
N = int(input())
cnt = np.zeros((10, 10))
for x in map(str, range(0, N + 1)):
	cnt[int(x[0]), int(x[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += cnt[i, j] * cnt[j, i]
print(int(ans))


N = int(input())
ans = 0
ary = [0] * 100
for n in range(1, N + 1):
	s = str(n)
	ary[int(s[0]) * 10 + int(s[-1])] += 1
for i in range(10, 100):
	s = str(i)
	j = int(s[-1]) * 10 + int(s[0])
	ans += ary[i] * ary[j]
print(ans)


N = int(input())
memo = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
	s = str(i)
	memo[int(s[0])][int(s[-1])] += 1
rlt = 0
for i in range(1, 10):
	for j in range(1, 10):
		rlt += memo[i][j] * memo[j][i]
print(rlt)


from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n + 1):
	s = str(i)
	d[s[0], s[-1]] += 1
ans = 0
x = list(d.keys())
for i in x:
	ans += d[i[::-1]] * d[i]
print(ans)


N = int(input())
a = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
	s = str(i)
	a[int(s[0])][int(s[-1])] += 1
ans = sum((a[i][j] * a[j][i] for i in range(10) for j in range(10)))
print(ans)


from collections import defaultdict
n = int(input())
dct = defaultdict(int)
for i in range(1, n + 1):
	s = str(i)
	dct[s[0], s[-1]] += 1
ans = 0
for i in range(1, n + 1):
	s = str(i)
	ans += dct[s[-1], s[0]]
print(ans)


from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n + 1):
	if str(i)[-1] == '0':
		continue
	d[int(str(i)[0] + str(i)[-1])] += 1
ans = 0
for i in range(11, 100):
	ans += d[i] * d[int(str(i)[1] + str(i)[0])]
print(ans)


n = int(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(input())
DP = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N + 1):
	DP[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += DP[i][j] * DP[j][i]
print(ans)


N = int(input())
num = [[0] * 10 for i in range(10)]
for i in range(1, N + 1):
	num[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(1, N + 1):
	ans += num[int(str(i)[-1])][int(str(i)[0])]
print(ans)


n = int(input())
t = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
	t[int(str(i)[0])][int(str(i)[-1])] += 1
g = 0
for i in range(1, 10):
	for j in range(1, 10):
		g += t[i][j] * t[j][i]
print(g)


N = int(input())
t = [[0] * 10 for _ in range(10)]
cnt = 0
for i in range(N + 1):
	s = str(i)
	t[int(s[0])][int(s[-1])] += 1
for i in range(1, 10):
	for j in range(1, 10):
		cnt += t[i][j] * t[j][i]
print(cnt)


def solve():
	N = int(input())
	cnt = [[0] * 10 for i in range(10)]
	for i in range(1, N + 1):
		target_str = str(i)
		cnt[int(target_str[0])][int(target_str[-1])] += 1
	ans = 0
	for i in range(1, 10):
		for j in range(1, 10):
			ans += cnt[i][j] * cnt[j][i]
	print(ans)

def __starting_point():
	solve()
__starting_point()


n = int(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(input())
l = [[0] * 10 for _ in range(10)]
for x in range(1, n + 1):
	l[int(str(x)[0])][int(str(x)[-1])] += 1
print(sum((l[i][j] * l[j][i] for i in range(10) for j in range(10))))


l = [0] * 100
r = range(10)
for i in range(int(input())):
	s = str(i + 1)
	l[int(s[0] + s[-1])] += 1
print(sum([l[i * 10 + j] * l[j * 10 + i] for i in r for j in r]))


N = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N + 1):
	c[int(str(i)[0])][int(str(i)[-1])] += 1
cnt = 0
for i in range(10):
	for j in range(10):
		cnt += c[i][j] * c[j][i]
print(cnt)


import sys
import math

def count(a, b, N):
	keta = len(str(N))
	cnt = 0
	if a == b:
		cnt += 1 if a <= N else 0
	if keta == 1:
		return cnt
	if keta == 2:
		cnt += 1 if b * 10 + a <= N else 0
		return cnt
	for k in range(2, keta):
		cnt += 10 ** (k - 2)
	s = N // 10 ** (keta - 1)
	t = N % 10
	if b > s:
		return cnt
	elif b < s:
		cnt += 10 ** (keta - 2)
	else:
		tempN = (N - s * 10 ** (keta - 1) - t) // 10
		cnt += tempN + 1
		if a > t:
			cnt -= 1
	return cnt

def count_aa(a, N):
	keta = len(str(N))
	cnt = 0
	if keta == 1:
		return 1 if a <= N[-1] else 0
	cnt += 1
	if keta == 2:
		return cnt + 1 if a <= N[-1] else 0
	for k in range(2, keta):
		cnt += 10 ** (k - 2)
	s = N // 10 ** (keta - 1)
	t = N % 10
	if b > s:
		return cnt
	elif b < s:
		cnt += 10 ** (keta - 2)
	else:
		tempN = (N - s * 10 ** (keta - 1) - t) // 10
		cnt += tempN + 1
		if a > t:
			cnt -= 1
	return cnt
N = int(input())
c = 0
for i in range(1, N + 1):
	a = int(str(i)[0])
	b = i % 10
	if b == 0:
		continue
	c += count(a, b, N)
print(c)


n = int(input())
d = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
	(a, b) = map(int, [str(i)[0], str(i)[-1]])
	d[a][b] += 1
cnt = 0
for i in range(1, 10):
	for j in range(1, 10):
		cnt += d[i][j] * d[j][i]
print(cnt)


N = int(input())
dp = [[0 for i in range(10)] for j in range(10)]
for i in range(1, N + 1):
	i = str(i)
	dp[int(i[0])][int(i[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += dp[i][j] * dp[j][i]
print(ans)


from collections import defaultdict
N = int(input())
head_tail = defaultdict(int)
for i in range(1, N + 1):
	tail = i % 10
	head = int(str(i)[0])
	head_tail[head, tail] += 1
answer = 0
for i in range(1, N + 1):
	head = int(str(i)[0])
	tail = i % 10
	answer += head_tail[tail, head]
print(answer)


from collections import defaultdict
N = int(input())
cnts = defaultdict(int)
for i in range(1, N + 1):
	if i % 10 == 0:
		continue
	digits = []
	while i > 0:
		(i, r) = divmod(i, 10)
		digits.append(r)
	digits = digits[::-1]
	cnts[digits[0], digits[-1]] += 1
ans = 0
for ((head, tail), c1) in list(cnts.items()):
	c2 = cnts.get((tail, head), 0)
	ans += c1 * c2
print(ans)


N = int(input())
dp = [0] * 100
for i in range(N):
	s = str(i + 1)
	dp[int(s[0]) * 10 + int(s[-1])] += 1
ans = sum((dp[i * 10 + j] * dp[j * 10 + i] for i in range(1, 10) for j in range(1, 10)))
print(ans)


n = int(input())
l = [[0] * 10 for i in range(10)]
for i in range(n):
	t = str(i + 1)
	l[int(t[0])][int(t[-1])] += 1
a = 0
for i in range(10):
	for j in range(10):
		a += l[i][j] * l[j][i]
print(a)


n = int(input())
m = [0] * 100
for i in range(1, n + 1):
	if str(i)[-1] != '0':
		m[int(str(i)[0]) * 10 + int(str(i)[-1])] += 1
res = sum([m[i] * m[int(str(i)[::-1])] for i in range(100)])
print(res)


n = int(input())
A = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
	t = str(i)
	(a, b) = (int(t[0]), int(t[-1]))
	A[a][b] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += A[i][j] * A[j][i]
print(ans)


N = int(input())
l = [[0 for j in range(10)] for i in range(10)]
for n in range(1, N + 1):
	s = str(n)
	i = int(s[0])
	j = int(s[-1])
	l[i][j] += 1
ans = sum([l[i][j] * l[j][i] for i in range(10) for j in range(10)])
print(ans)


x = int(input())
dp = [[0 for n in range(10)] for n in range(10)]
dp1 = dp.copy()
for n in range(x + 1):
	v = str(n)
	p = int(v[0])
	q = int(v[-1])
	for a in range(10):
		for b in range(10):
			if a == p and b == q:
				dp[a][b] += 1
res = -1
for n in range(10):
	for k in range(10):
		res += dp[n][k] * dp[k][n]
print(res)


N = int(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)


n = int(input())
cnt = [[0 for i in range(10)] for j in range(10)]
for k in range(n + 1):
	head = int(str(k)[0])
	foot = int(str(k)[-1])
	cnt[head][foot] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += cnt[i][j] * cnt[j][i]
print(ans)


n = int(input())
a = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	a[int(str(i)[0])][i % 10] += 1
ans = 0
for x in range(1, 10):
	ans += a[x][x] ** 2
	for y in range(x + 1, 10):
		ans += a[y][x] * a[x][y] * 2
print(ans)


n = int(input())
memo = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
	a = int(str(i)[0])
	b = int(str(i)[-1])
	memo[a][b] += 1
ans = 0
for i in range(1, n + 1):
	b = int(str(i)[0])
	a = int(str(i)[-1])
	ans += memo[a][b]
print(ans)


N = int(input())
t = [0] * 100
ans = 0
for k in range(1, N + 1):
	if k % 10 != 0:
		t[10 * int(str(k)[0]) + int(str(k)[-1])] += 1
for k in range(11, 100):
	if k % 10 != 0:
		ans += t[k] * t[10 * (k % 10) + k // 10]
print(ans)


N = int(input())
num = [[0] * 10 for i in range(10)]
for i in range(1, N + 1):
	top = int(str(i)[0])
	end = int(str(i)[-1])
	num[top][end] += 1
count = 0
for i in range(10):
	for j in range(10):
		count += num[i][j] * num[j][i]
print(count)


N = int(input())
arr = [0] * 100
for num in range(1, N + 1):
	arr[int(str(num)[0] + str(num)[-1])] += 1
print(sum([arr[i * 10 + j] * arr[j * 10 + i] for i in range(10) for j in range(10)]))


n = int(input())
a = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n + 1):
	s = str(i)
	if s[-1] != '0':
		a[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += a[i][j] * a[j][i]
print(ans)


n = int(input())
ans = 0
X = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	t = int(str(i)[0])
	b = int(str(i)[-1])
	X[t][b] += 1
for i in range(1, 10):
	for j in range(1, 10):
		ans += X[i][j] * X[j][i]
print(ans)


n = int(input())
res = 0
M = [[0 for _ in range(10)] for _ in range(10)]
for i in range(n + 1):
	a = i % 10
	b = int(str(i)[0])
	M[a][b] += 1
for i in range(1, 10):
	for j in range(1, 10):
		res += M[i][j] * M[j][i]
print(res)


N = int(input())
LUT = [[0] * 10 for _ in range(10)]
for n in range(1, N + 1):
	LUT[int(str(n)[0])][int(str(n)[-1])] += 1
ans = sum([sum([LUT[i][j] * LUT[j][i] for i in range(10)]) for j in range(10)])
print(ans)


n = int(input())
cnt = 0
memo = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	memo[int(str(i)[0])][int(str(i)[-1])] += 1
for i in range(10):
	for j in range(10):
		cnt += memo[i][j] * memo[j][i]
print(cnt)


N = int(input())
D = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
	s = str(n)
	i = int(s[0])
	j = int(s[-1])
	D[i][j] += 1
r = 0
for i in range(10):
	for j in range(10):
		r += D[i][j] * D[j][i]
print(r)


n = int(input())
D = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
	s = str(i)
	D[int(s[0])][int(s[-1])] += 1
a = 0
for i in range(10):
	for j in range(10):
		a += D[i][j] * D[j][i]
print(a)


def main():
	N = int(input())
	comb_count = [[0 for i in range(10)] for j in range(10)]
	res = 0
	for i in range(1, N + 1):
		s = str(i)
		(max, min) = (int(s[0]), int(s[-1]))
		comb_count[max][min] += 1
	for l in range(1, 10):
		for r in range(1, 10):
			res += comb_count[l][r] * comb_count[r][l]
	print(res)

def __starting_point():
	main()
__starting_point()


n = int(input())
p = [[0 for _ in range(10)] for _2 in range(10)]
ans = 0
for i in range(1, n + 1):
	l = int(str(i)[0])
	r = int(str(i)[-1])
	ans += 2 * p[r][l]
	p[l][r] += 1
	if l == r:
		ans += 1
print(ans)


N = int(input())
c = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
	c[int(str(n)[0])][int(str(n)[-1])] += 1
sum = 0
for i in range(10):
	for j in range(10):
		sum += c[i][j] * c[j][i]
print(sum)


N = int(input())
(a, b) = divmod(N, 10)
h = lambda n: h(n // 10) if n > 9 else n
print(a ** 2 + 8 + sum(((h(i) <= b) * (i % 10 == h(N)) * (1 + (a != i // 10)) for i in range(1, N + 1))) if a else N)


n = int(input())
t = [0] * 100
for i in range(11, 100):
	msb = i // 10
	lsb = i % 10
	if lsb == 0:
		continue
	for j in range(1, n + 1):
		if j % 10 == lsb and int(str(j)[0]) == msb:
			t[i] += 1
ans = 0
for i in range(11, 100):
	msb = i // 10
	lsb = i % 10
	if lsb == 0:
		continue
	if msb == lsb:
		ans += t[i] ** 2
	else:
		ans += t[i] * t[lsb * 10 + msb]
print(ans)


import collections
d = collections.defaultdict(int)
n = int(input())
for i in range(1, n + 1):
	s = str(i)
	d[s[0], s[-1]] += 1
ans = 0
for i in range(1, n + 1):
	s = str(i)
	ans += d[s[-1], s[0]]
print(ans)


n = int(input())
dp = [[0] * 10 for i in range(10)]
su = 0
for i in range(1, n + 1):
	(a, b) = (str(i)[0], str(i)[-1])
	dp[int(a) - 1][int(b) - 1] += 1
for i in range(10):
	for j in range(10):
		su += dp[i][j] * dp[j][i]
print(su)


n = int(input())
count = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for _ in range(10)]
for i in range(1, n + 1):
	count[int(list(str(i))[0]) - 1][int(list(str(i))[-1]) - 1] += 1
ans = 0
for j in range(10):
	for k in range(10):
		ans += count[j][k] * count[k][j]
print(ans)


N = int(input())
D = {}
for i in range(1, N + 1):
	i = str(i)
	D[i[0], i[-1]] = D.get((i[0], i[-1]), 0) + 1
ans = 0
for i in range(1, N + 1):
	i = str(i)
	ans += D.get((i[-1], i[0]), 0)
print(ans)


n = int(input())
a = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	keta = str(i)[0]
	makkou = str(i)[-1]
	a[int(makkou) - 1][int(keta) - 1] += 1
ans = 0
for j in range(10):
	for i in range(10):
		ans += a[j][i] * a[i][j]
print(ans)


from collections import Counter
N = int(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 c.items():
	ans += v * c[k[1], k[0]]
print(ans)


N = int(input())
l = [[0] * 10 for i in range(10)]
for i in range(1, N + 1):
	s = len(str(i))
	if s == 1:
		l[i][i] += 1
	else:
		l[i // 10 ** (s - 1)][i % 10] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += l[i][j] * l[j][i]
print(ans)


n = int(input())
lr_cnt = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
	str_i = str(i)
	start = int(str_i[0])
	end = int(str_i[-1])
	lr_cnt[start][end] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += lr_cnt[i][j] * lr_cnt[j][i]
print(ans)


import math

def comb(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N = int(input())
Comlist = []
Ans = dict()
Answer = 0
for i in range(1, 10):
	for j in range(1, 10):
		M = i * 10 + j
		Comlist.append(str(M))
		Ans[str(M)] = 0
for k in range(1, N + 1):
	strk = str(k)
	if k < 10:
		Tar = strk + strk
		Ans[Tar] += 1
	else:
		Tar = strk[0] + strk[-1]
		if Tar in Ans:
			Ans[Tar] += 1
Answer = 0
for q in range(len(Comlist)):
	p = Comlist[q]
	pin = p[1] + p[0]
	Answer += Ans[p] * Ans[pin]
print(Answer)


n = int(input())
a = [0] * 100
count = 0
for i in range(1, n + 1):
	x = i % 10
	y = int(str(i)[0])
	a[10 * y + x] += 1
for i in range(1, n + 1):
	x = i % 10
	y = int(str(i)[0])
	count += a[10 * x + y]
print(count)


N = int(input())
count = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
	s = str(i)
	head = int(s[0])
	tail = int(s[-1])
	count[head][tail] += 1
ans = 0
for a in range(1, N + 1):
	s = str(a)
	head = int(s[0])
	tail = int(s[-1])
	ans += count[tail][head]
print(ans)


def N():
	return int(input())

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

def NL(n):
	return [list(map(int, input().split())) for i in range(n)]
mod = pow(10, 9) + 7
import sys
import math
import collections
n = N()
c = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	h = int(str(i)[0])
	t = int(str(i)[-1])
	c[h][t] += 1
sum = 0
for i in range(1, 10):
	for j in range(1, 10):
		sum += c[i][j] * c[j][i]
print(sum)


n = int(input())
hist = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
	top = int(str(i)[0])
	bot = int(str(i)[-1])
	hist[top][bot] += 1
ans = 0
for i in range(1, n + 1):
	top = int(str(i)[0])
	bot = int(str(i)[-1])
	ans += hist[bot][top]
print(ans)


n = int(input())
l = [0] * 100
ans = 0
for i in range(1, n + 1):
	s = str(i)
	l[int(s[0]) * 10 + int(s[-1])] += 1
for i in range(1, 10):
	for j in range(1, 10):
		ans += l[i * 10 + j] * l[j * 10 + i]
print(ans)


from collections import defaultdict
n = int(input())
counter = defaultdict(int)
for x in map(str, range(1, n + 1)):
	head = x[0]
	tail = x[-1]
	counter[head, tail] += 1
ans = 0
items = list(counter.items())
for ((head, tail), cnt) in items:
	ans += cnt * counter[tail, head]
print(ans)


import sys
from itertools import chain

def solve(N: int):
	m = [0] * 100
	for n in range(N + 1):
		s = str(n)
		h = int(s[0])
		l = int(s[-1])
		if l != 0:
			m[h * 10 + l] += 1
	answer = 0
	for h in range(1, 10):
		for l in range(1, 10):
			answer += m[h * 10 + l] * m[l * 10 + h]
	return answer

def main():
	N = int(input())
	answer = solve(N)
	print(answer)

def __starting_point():
	main()
__starting_point()


N = int(input())
d = dict()
for i in range(1, N + 1):
	_0 = str(i)[0]
	_1 = str(i)[-1]
	if _1 == '0':
		continue
	s = _0 + _1
	if s in d:
		d[s] += 1
	else:
		d[s] = 1
res = 0
for i in range(1, N + 1):
	_0 = str(i)[0]
	_1 = str(i)[-1]
	if _1 == '0':
		continue
	s = _1 + _0
	if s in d:
		res += d[s]
print(res)


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


n = int(input())
A = [0] * 105
for i in range(1, n + 1):
	x = str(i)
	A[int(x[0] + x[len(x) - 1])] += 1
ans = 0
for i in range(11, 100):
	y = str(i)
	if '0' in y:
		continue
	ans += A[i] * A[int(y[1] + y[0])]
print(ans)


from collections import defaultdict
N = int(input())
d = defaultdict(int)
for i in range(1, N + 1):
	s = str(i)
	d[s[0], s[-1]] += 1
ans = 0
for i in range(1, N + 1):
	s = str(i)
	ans += d[s[-1], s[0]]
print(ans)


n = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(1, n + 1):
	d[str(i)[0] + str(i)[-1]] += 1
sm = 0
for i in range(1, 10):
	for j in range(1, 10):
		sm += d[str(i) + str(j)] * d[str(j) + str(i)]
print(sm)


n = int(input())
d = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	i_ = str(i)
	x = int(i_[0])
	y = int(i_[-1])
	d[x][y] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += d[i][j] * d[j][i]
print(ans)


n = input()
d = [[0] * 10 for _ in range(10)]
for i in range(1, int(n) + 1):
	k = str(i)
	d[int(k[0])][int(k[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += d[i][j] * d[j][i]
print(ans)


N = int(input())
d = {}
for i in range(1, 10):
	for j in range(1, 10):
		d[i * 10 + j] = 0
for i in range(1, min(10, N + 1)):
	d[i * 10 + i] = 1
(p, h, t, c) = (10, 10, 1, 1)
for i in range(11, N + 1):
	if t == 10:
		t = 1
	else:
		d[h + t] += 1
		t += 1
	if p == c:
		h += 10
		c = 0
	if h == 100:
		h = 10
		p *= 10
	c += 1
ans = 0
for i in range(1, 9):
	for j in range(i + 1, 10):
		ans += d[i * 10 + j] * d[j * 10 + i] * 2
for i in range(1, 10):
	ans += d[i * 10 + i] ** 2
print(ans)


N = int(input())
ab = [[0 for i in range(9)] for j in range(9)]
for i in range(1, N + 1):
	if i % 10 != 0:
		s = str(i)
		ab[int(s[0]) - 1][int(s[-1]) - 1] += 1
ans = 0
for i in range(9):
	for j in range(9):
		ans += ab[i][j] * ab[j][i]
print(ans)


N = int(input())
A = [str(i) for i in range(1, 10)]
ans = 0
for a in A:
	for b in A:
		countA = 0
		if a == b and int(a) <= N:
			countA += 1
		for i in range(5):
			m = int(a + '0' * i + b)
			M = int(a + '9' * i + b)
			if m <= N:
				if M <= N:
					countA += 10 ** i
				else:
					while m <= N:
						countA += 1
						m += 10
		countB = 0
		if b == a and int(b) <= N:
			countB += 1
		for i in range(5):
			m = int(b + '0' * i + a)
			M = int(b + '9' * i + a)
			if m <= N:
				if M <= N:
					countB += 10 ** i
				else:
					while m <= N:
						countB += 1
						m += 10
		ans += countA * countB
print(ans)


N = int(input())
C = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
	C[int(str(i)[0])][int(str(i)[-1])] += 1
answer = 0
for i in range(10):
	for j in range(10):
		answer += C[i][j] * C[j][i]
print(answer)


def main():
	n = int(input())
	dp = [[0 for i in range(10)] for i in range(10)]
	for i in range(1, n + 1):
		(h, t) = (int(str(i)[0]), int(str(i)[-1]))
		dp[h][t] += 1
	ans = 0
	for i in range(10):
		for j in range(10):
			ans += dp[i][j] * dp[j][i]
	print(ans)

def __starting_point():
	main()
__starting_point()


N = int(input())
C = [[0] * 10 for _ in range(10)]
for n in range(1, N + 1):
	s = str(n)
	C[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += C[i][j] * C[j][i]
print(ans)


n = int(input())
a = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
	j = i % 10
	while i > 9:
		i //= 10
	a[i][j] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += a[i][j] * a[j][i]
print(ans)


from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(1, n + 1):
	s = str(i)
	f = int(s[0])
	b = int(s[-1])
	d[f, b] += 1
ans = 0
for a in range(1, 10):
	for b in range(1, 10):
		ans += d[a, b] * d[b, a]
print(ans)


n = int(input())
c = [[0] * 10 for i in range(10)]
for i in range(1, n + 1):
	t = int(str(i)[0])
	b = int(str(i)[-1])
	c[t][b] += 1
s = 0
for t in range(10):
	for b in range(10):
		s += c[t][b] * c[b][t]
print(s)


N = int(input())
A = [0] * 100
for i in range(1, N + 1):
	first = int(str(i)[0])
	last = int(str(i)[-1])
	A[first * 10 + last] += 1
score = 0
for i in range(10):
	for j in range(10):
		score += A[i * 10 + j] * A[j * 10 + i]
print(score)


n = int(input())
lst = [[0 for i in range(10)] for j in range(10)]
cnt = 0
for i in range(1, n + 1):
	(l, r) = (int(str(i)[0]), int(str(i)[-1]))
	lst[l][r] += 1
for i in range(10):
	for j in range(10):
		cnt += lst[i][j] * lst[j][i]
print(cnt)


N = int(input())
data = [[0] * 10 for i in range(10)]
for u in range(N + 1):
	data[int(str(u)[0])][int(str(u)[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += data[i][j] * data[j][i]
print(ans)


N = int(input())
k = [[0] * 10 for _ in range(10)]
for n in range(1, N + 1):
	sn = str(n)
	k[int(sn[0])][int(sn[-1])] += 1
ans = 0
for i in range(1, 10):
	for j in range(1, 10):
		ans += k[i][j] * k[j][i]
print(ans)


n = int(input())
c = []
for i in range(0, 10):
	c.append([0] * 10)
for k in range(1, n + 1):
	x = str(k)
	a = int(x[0])
	b = int(x[-1])
	c[a][b] += 1
s = 0
for i in range(1, 10):
	for j in range(1, 10):
		s += c[i][j] * c[j][i]
print(s)


n = int(input())
t = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
	si = str(i)
	t[int(si[0])][int(si[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += t[i][j] * t[j][i]
print(ans)


import sys
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_ints2(x):
	return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def GCD(a: int, b: int) -> int:
	return b if a % b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
	return a * b // GCD(a, b)

def f(num):
	front = num
	back = num
	while front >= 10:
		front //= 10
	while back >= 10:
		back %= 10
	return (front, back)

def Main():
	n = read_int()
	cnt = [[0] * 10 for _ in range(10)]
	for x in range(1, n + 1):
		(front, back) = f(x)
		cnt[front][back] += 1
	ans = 0
	for x in range(10):
		for y in range(10):
			ans += cnt[x][y] * cnt[y][x]
	print(ans)

def __starting_point():
	Main()
__starting_point()


n = int(input())
g = [[0] * 10 for _ in range(10)]
for i in range(1, 1 + n):
	a = int(str(i)[0])
	b = i % 10
	g[a][b] += 1
ans = sum((g[a][b] * g[b][a] for a in range(10) for b in range(10)))
print(ans)


N = int(input())
bucket = [[0] * 10 for _ in range(10)]
for n in range(1, N + 1):
	n = str(n)
	bucket[int(n[0])][int(n[-1])] += 1
ans = 0
for i in range(10):
	for j in range(10):
		ans += bucket[i][j] * bucket[j][i]
print(ans)


n = int(input())
a = [[0 for j in range(10)] for i in range(10)]
for i in range(1, n + 1):
	if i >= 10 ** 5:
		tmp1 = i // 10 ** 5
	elif i >= 10 ** 4:
		tmp1 = i // 10 ** 4
	elif i >= 10 ** 3:
		tmp1 = i // 10 ** 3
	elif i >= 10 ** 2:
		tmp1 = i // 10 ** 2
	elif i >= 10:
		tmp1 = i // 10
	else:
		tmp1 = i
	tmp2 = i % 10
	a[tmp1][tmp2] += 1
cnt = 0
for i in range(1, 10):
	for j in range(1, 10):
		cnt += a[i][j] * a[j][i]
print(cnt)


n = int(input())
cnt = [[0] * 10 for i in range(10)]
for i in range(n + 1):
	a = int(str(i)[0])
	b = int(str(i)[-1])
	if a == 0 or b == 0:
		continue
	cnt[a][b] += 1
ans = 0
for i in range(n + 1):
	a = int(str(i)[0])
	b = int(str(i)[-1])
	ans += cnt[b][a]
print(ans)


n = int(input())
a = [[0] * 9 for _ in range(9)]
for i in range(1, n + 1):
	s = str(i)
	l = int(s[0])
	r = int(s[len(s) - 1])
	if l * r != 0:
		a[l - 1][r - 1] += 1
x = 0
for i in range(9):
	for j in range(9):
		x += a[i][j] * a[j][i]
print(x)


N = int(input())
M = [0] * 100
for i in range(1, N + 1):
	i = str(i)
	(l, r) = (int(i[0]), int(i[-1]))
	M[l * 10 + r] += 1
ans = 0
for (i, cnt) in enumerate(M):
	(l, r) = divmod(i, 10)
	ans += cnt * M[r * 10 + l]
print(ans)


n = int(input())
dat = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
	dat[int(str(i)[0])][int(str(i)[-1])] += 1
res = sum([dat[a][b] * dat[b][a] for a in range(10) for b in range(10)])
print(res)