MOV A 0
MOV B 0

MOV C 0
MOV D 0
MOV E 0
MOV F 0
MOV G 0

MOV H 0
MOV RES 0

IN A
IN B

CMP B H
JNZ 53
MOV H 1
SUB B H

  IN C
  IN D
  IN E
  CMP C H
  JNZ 36
  JZ 28

  IN F
  CMP D E
  JZ 49
  LOAD D G
  ADD G F
  STORE D G
  JZ 43
  
  MOV F 0
  CMP D E
  JZ 49
  LOAD D G
  ADD F G
  JNZ 43

  MOV H 1
  ADD D H
  MOV H 0
  JZ 29
  JNZ 36

JZ 16
OUT F
JNZ 16

RETURN