(letrec* ((n (read)) (m (read)) (p (read)) (q (read)) (r (make-vector 12 1)) (r-init (lambda (i j) (unless (> i j) (begin (set! (~ r (- i 1)) 2) (r-init (+ i 1) j))))) (check (lambda (rest a a1) (let1 rest1 (- rest (* m (~ r a1))) (if (<= rest1 0) (+ a 1) (check rest1 (+ a 1) (if (= 11 a1) 0 (+ a1 1)))))))) (r-init p (- (+ p q) 1)) (print (check n 0 0)))