program ddd
implicit none

integer :: n, i, p, q, r, x, y, res, chk, co
integer,dimension(99) :: t
character(10) :: c

t = 0
read*, n


if(n<10) then
print*, n
return
end if

do i = 10, n

write(c,'(i10)') i

c = adjustl(c)
r = len_trim(c)
read(c(1:1),*) x
read(c(r:r),*) y
p = max(x,y)
q = min(x,y)

if (q==0) cycle
t(10*x+y) = t(10*x+y) + 1

end do

chk = 0
res = 9
do i = 1, 9
co = 11*i
if (t(co)>0) then
t(co) = t(co) + 1
chk = chk + 1
res = res + t(co)**2
end if
end do

do i = 12, 99

if (t(i)==0) cycle
x = int(i*0.1)
y = i - 10*x

if (y==0) cycle
if (mod(i,11)==0) cycle

p = t((10*x) + y)
q = t((10*y) + x)
res = res + p*q
end do

print*, res - chk

end program