let rec sqrt n guess = let curGuess = match guess with | None -> n / 2m | Some(x) -> x let res = n / curGuess let ave = (curGuess + res) / 2m if ave = curGuess then ave else sqrt n (Some(ave)) let isInt (n:decimal) = let str = n.ToString().Split('.') str.Length > 1 && str.[1].ToCharArray() |> Array.forall(fun x -> x ='0') let isValid n = let f n = ((sqrt (8m * n + 1m) None )-1m)/2m let res = f n if res |> isInt then printfn "YES" printfn "%i" <| (int res) else printfn "NO" let n = stdin.ReadLine() |> decimal n |> isValid