IDENTIFICATION DIVISION.
PROGRAM-ID. 174D.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
  SELECT STDIO ASSIGN TO KEYBOARD. 
*>
DATA DIVISION.
FILE SECTION.
FD STDIO.
01 INP        PIC  X(200000).
*>
WORKING-STORAGE SECTION.
01 N          PIC  9(06).
01 TBL1.
   03 C       PIC  X(01) OCCURS 200000.
01 I          PIC  9(06) COMP.
01 R-C        PIC  9(06).
01 CNT        PIC  9(06).
01 OUT        PIC  Z(05)9.
*> 
PROCEDURE DIVISION.
  ACCEPT N.
*>
  OPEN INPUT STDIO.
  READ STDIO.
  CLOSE STDIO.
  MOVE INP   TO TBL1.
*>
  INSPECT INP TALLYING R-C FOR ALL 'R'
*>
  MOVE ZERO TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > R-C
    IF (C(I) = 'W') 
      ADD  1 TO CNT
    END-IF
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
