(define (System.out.println x) (begin (display x) (newline) ) ) (define (CntBin1 foo) (if (<= foo 2) 1 (if (= (modulo foo 2) 0) (CntBin1 (/ foo 2)) (+ 1 (CntBin1 (/ (- foo 1) 2))) ) ) ) (let ( (N (read)) ) (let loop( (i 1) (Grid 1) ) (if (= Grid N) (System.out.println i) (if (<= (+ Grid (CntBin1 Grid)) N) (loop (+ i 1) (+ Grid (CntBin1 Grid))) (if (>= i N) (System.out.println -1) (loop (+ i 1) (- Grid (CntBin1 Grid))) ) ) ) ) )