program main
    implicit none
    integer:: fep(0:9,0:9), n,i, top, bottom, count, j

    fep(:,:) = 0

    read*, n

    do i = 1, n
        top = i
        do while (top >= 10)
            top = top / 10
        end do
        bottom = mod(i, 10)
        fep(top,bottom) = fep(top,bottom) + 1
    end do
    
    count = 0
    do i = 1, 9
        count = count + fep(i,i)*fep(i,i)
        do j = i+1,9
             count = count + fep(i,j)*fep(j,i)*2
        end do
    end do
    print*, count
end program main