(define a (read)) (define b (read)) (define c (read)) (define d (read)) (define m (read)) (define ans 0) (dotimes [i (- b a -1)] (dotimes [j (- d c -1)] (set! ans (max ans (mod (+ a c i j) m))))) (print ans)