print+($%=$'/($d=$`-<>=~/ .* /+$&))*$`+($'%$d<$`?$'%$d:$`)|0