program name

    implicit none
    integer a,b,i,ii,counter
    character(5) num_str,str_return
    read*, a,b
    counter = 0
    do i = a, b, 1
        write(i,*) num_str
        str_return = ""
        do ii = 5, 1, -1
            str_return = str_return//num_str(ii)
        end do
        if ( num_str==str_return ) then
            counter = counter + 1
        end if
    end do
print*, counter
end program