IDENTIFICATION DIVISION.
PROGRAM-ID. 147B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP   PIC X(100).
01 S     PIC X(100).
01 N     PIC 9(3).
01 H     PIC 9(2).
01 I     PIC 9(3).
01 J     PIC 9(3).
01 OUT-H PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO S COUNT N.
*>
  MOVE 0  TO H.
  MOVE 1  TO I.
  MOVE N  TO J.
  PERFORM UNTIL I >= J
    IF (S(I:1) NOT = S(J:1))
      ADD 1 TO H
    END-IF
    ADD      1 TO   I
    SUBTRACT 1 FROM J
  END-PERFORM.
*>
  MOVE H TO OUT-H.
  DISPLAY OUT-H.
*>
  STOP RUN.
