(define (main args) (let* ( (a (read)) (b (read)) (c (read)) (d (read)) ) (let loop ((n 0)) (if (equal? (modulo (+ (* a n) c) b) d) (print (+ c (* a n))) (loop (+ n 1))))) 0)