lib C fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64 end class String def to_i64 C.strtoll(self, nil, 10) end end def func(n) x = 0i64 while n > 0 x += n n //= 2 end x end n = read_line.to_i64 x = (1..n).bsearch { |x| func(x) >= n } puts func(x.not_nil!) == n ? "YES" : "NO"