program main
implicit none
integer :: i, j, n
integer :: nc_jpy, nc_btc
character(len=3) , allocatable :: cmoney(:)
real(8) , allocatable :: x(:)
real(8) :: y
real(8), parameter :: btc_jpy = 380000.

read(*,*) n
allocate(x(n))
allocate(cmoney(n))
nc_jpy = 0
nc_btc = 0
do i = 1, n
   read(*,*) x(i), cmoney(i)
   if (cmoney(i) == 'JPY') then
      nc_jpy = nc_jpy + x(i)
   else
      nc_btc = nc_btc + x(i)
   end if
end do

y = btc_jpy*nc_btc + nc_jpy
write(*,*) y

end program main
