import Control.Applicative ((<$>)) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import Text.Printf main :: IO () main = printf "%.5f" =<< solve <$> B.getLine solve :: ByteString -> Double solve bs = sqrt (s * s + t * t) where (x, y) = B.foldl' f (0, 0) bs (s, t) = (fromIntegral x, fromIntegral y) f :: (Int, Int) -> Char -> (Int, Int) f (x, y) c | c == 'N' = (x, y + 1) | c == 'E' = (x + 1, y) | c == 'W' = (x - 1, y) | c == 'S' = (x, y - 1) | otherwise = (x, y)