implicit none
integer(8) N,i,U,V
real(8),allocatable :: T(:)
character(100),allocatable :: S(:)
read(*,*) N
U=0
V=0
allocate (T(N))
allocate (S(N))
do i=1,N
   read(*,*) T(i:i),S(i:i)
end do
do i=1,N
   V=V+len_trim(S(i))
   T(i:i)=int((T(i:i)*12.0)/1000.0)
   if (T(i)>len_trim(S(i))) then
            U=U+len_trim(S(i))
   else
            U=U+T(i)
   end if
end do
write(*,*) U,V-U
end