2865 FOR KI=1 TO NM