program ABC152D
    implicit none
    integer(8)::N,i,j,top,tail
    integer(8)::result=0
    integer(8),dimension(10,10)::C
    read(5,*)N
    C=0

    do i=1,N
        tail=mod(i,10)
        j=i
        top=i
        do
            j=j/10
            if(j==0)then
                exit
            end if
            top=j
        end do
        C(top+1,tail+1)=C(top+1,tail+1)+1
    end do

    do i=1,10
        do j=1,10
            result=result+C(i,j)*C(j,i)
        end do
    end do

    print'(i0)',result
end program ABC152D