IDENTIFICATION DIVISION.
PROGRAM-ID. 159A.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 N          PIC 9(3).
01 M          PIC 9(3).
01 OUT        PIC ZZZZ9.
*>
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO N M.
*>
  EVALUATE TRUE
    WHEN N = 1 AND M = 1
      MOVE 0 TO OUT
    WHEN N <= 1 
      COMPUTE OUT =  M * (M - 1) / 2
    WHEN M <= 1 
      COMPUTE OUT =  N * (N - 1) / 2
    WHEN OTHER  
      COMPUTE OUT = N * (N - 1) / 2 + M * (M - 1) / 2
  END-EVALUATE.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
