use utf8; utf8::decode($_=<>); for$d(reverse 0..999){ if(/w{$d}/){ while(/([^w]+)w{$d}/g){ utf8::encode($a=$1.$/); print$a } exit; } }