IDENTIFICATION DIVISION.
PROGRAM-ID. A-Task.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP      PIC X(100).
01 A1       PIC 9(3).
01 A2       PIC 9(3).
01 A3       PIC 9(3).
 
01 OUT-COST PIC ZZ9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO A1 A2 A3.
 
  EVALUATE TRUE
    WHEN (A1 <= A2 AND A1 >= A3) OR
         (A1 >= A2 AND A1 <= A3)
      COMPUTE OUT-COST = A2 - A3    
    WHEN (A2 <= A1 AND A2 >= A3) OR
         (A2 >= A1 AND A2 <= A3)
      COMPUTE OUT-COST = A1 - A3    
    WHEN OTHER
      COMPUTE OUT-COST = A1 - A2    
  END-EVALUATE.

  DISPLAY OUT-COST.
 
MAIN-EXIT.
  STOP RUN.