let () = let rec charlist_of_string str n i = if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in Scanf.scanf "%s\n" @@ fun s -> let lst = charlist_of_string s (String.length s) 0 in let (x,y) = List.fold_left (fun (x,y) s -> match s with | 'N' -> (x,y+.1.) | 'E' -> (x+.1.,y) | 'W' -> (x-.1.,y) | 'S' -> (x,y-.1.)) (0.,0.) lst in Printf.printf "%.5f\n" (sqrt (x ** 2. +. y ** 2.))