IDENTIFICATION DIVISION.
PROGRAM-ID. aising-B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(400).
01 N          PIC 9(03).
01 A          PIC 9(03).
01 I          PIC 9(04) COMP.
01 P1         PIC 9(04) COMP.
01 P2         PIC 9(04) COMP.
01 S          PIC 9(02).
01 AMR        PIC 9(01).
01 SW-K       PIC 9(01).
01 CNT        PIC 9(03).
01 OUT        PIC ZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
*>
  MOVE ZERO TO CNT.
  MOVE 1    TO P1 SW-K.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO A
    DIVIDE A BY 2 GIVING S REMAINDER AMR
    IF (SW-K = 1 AND AMR = 1)
      ADD 1 TO CNT
    END-IF
    COMPUTE P1 = P2 + 1
    COMPUTE SW-K = 1- SW-K
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
