program ABC152F
    implicit none
    integer::N
    integer::MS(9,9)=0
    integer::i,j
    integer::ANS=0
    read*,N
    do i=1,N
        if(mod(i,10)/=0)then
            MS(S(i),mod(i,10))=MS(S(i),mod(i,10))+1
        endif
    end do
    do i=1,9
        do j=1,9
            ANS=ANS+MS(i,j)*MS(j,i)
        end do
    end do
    print"(i0)",ANS
contains
function S(Num)
    integer::num
    integer::k
    integer::S
    S=10
    do k=0,6
        if(NUM/10**k/=0)then
        S=min(S,NUM/10**k)
        endif
    end do
end function
end program ABC152F