program main
    use,intrinsic :: iso_fortran_env
    implicit none
    character(1000):: s
    character(1):: ls

    read*, s
    ls = s(len_trim(s):len_trim(s))
    print'(a)', trim(s)//merge("s ", "es", ls/="s")
end program main