(define (powmod b p m) (cond ((zero? p) 1) ((zero? b) 0) (else (if (zero? (mod p 2)) (letrec ((prev (powmod b (div p 2) m))) (mod (* prev prev) m)) (letrec ((prev (powmod b (- p 1) m))) (mod (* b prev) m)))))) (define (answer m) (mod (+ (mod 2017 m) (powmod (* 2017 2017) 2017 m)) m)) (print (answer (read)))