tailsさんのperl解 http://yukicoder.me/submissions/118774 がすごかった。

sed /u/s/$/ham/