structure Bag = struct datatype 'a tree = Leaf | Node of 'a * int * 'a tree * 'a tree val empty = Leaf fun size Leaf = 0 | size (Node (k, v, left, right)) = 1 + size left + size right fun add Leaf newKey = Node (newKey, 1, Leaf, Leaf) | add (Node (nodeKey, nodeValue, left, right)) newKey = if nodeKey = newKey then (Node (nodeKey, nodeValue + 1, left, right)) else if nodeKey < newKey then Node (nodeKey, nodeValue, left, add right newKey) else Node (nodeKey, nodeValue, add left newKey, right) fun values Leaf = [] | values (Node (_, v, left, right)) = [v] @ values left @ values right end fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun makeBag l = List.foldl (fn (a, acc) => Bag.add acc a) Bag.empty l val () = let val n = readInt () val a_s = List.tabulate (n, fn _ => readInt ()) val bag = makeBag a_s val ans = List.length (List.filter (fn v => v = 1) (Bag.values bag)) in print (Int.toString ans ^ "\n") end