func (a,b) [] = (a,b) func (a,b) (x:xs) | x == 'N' = func (a,b+1) xs | x == 'S' = func (a,b-1) xs | x == 'E' = func (a+1,b) xs | x == 'W' = func (a-1,b) xs | True = func (a,b) xs main = do getLine >>= print . (\(x,y) -> sqrt(fromIntegral(x*x + y*y))) . func (0,0)