remove the nth from end only for the right inputs