IDENTIFICATION DIVISION.
PROGRAM-ID. 150B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S    PIC X(51).
01 N    PIC 9(2).
01 I    PIC 9(2).
01 CNT  PIC 9(2).
01 OUT  PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT S.
  MOVE 0 TO CNT  
  MOVE 1 TO I
  PERFORM UNTIL I > N - 2
    IF (S(I:3) = 'ABC') 
      ADD 1 TO CNT
      ADD 3 TO I
    ELSE
      ADD 1 TO I
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY OUT.
*>
  STOP RUN.
