IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_101_C.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(14).
    02 INP2   PIC X(700000).
    01 maxlen PIC 9(1)  VALUE 2.
    01 cur    PIC 9(2)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 k      PIC 9(18).
    01 l      PIC 9(18).
    01 len    PIC 9(2).
    01 cnt    PIC 9(6).
    01 ans    PIC Z(18).
    01 X      PIC 9(6).
    01 R      PIC 9(6).
    01 FLG    PIC 9(1).
    01 NK1.
        03 NK11 OCCURS 2.
            05 NK PIC 9(6).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.
    ACCEPT INP2.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO NK(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    MOVE 0 TO cnt.
    MOVE 0 TO FLG.
    MOVE 0 TO l.

    PERFORM VARYING k FROM 1 BY 1 UNTIL NK(1) < k
        ADD 1 TO l

        IF l = 1 THEN
            ADD 1 TO cnt
        ELSE IF l = NK(2)
            MOVE 1 TO l
        END-IF

    END-PERFORM.

    MOVE cnt TO ans.

    DISPLAY ans.
    STOP RUN.
