pos($input) += $n * int((length('fred'.$1) - 1) / $n + 1);