program remaining_balls
  implicit none
  character(10) :: s, t, u
  integer :: a, b
  read(*,*) s, t
  read(*,*) a, b
  read(*,*) u
  if (u == s) then
    write(*,'(i0,x,i0)') a-1, b
  else
    write(*,'(i0,x,i0)') a, b-1
  end if
end program remaining_balls