PROGRAM ask
  IMPLICIT NONE
  INTEGER :: i, k

  OPEN(12, file="444.txt", action="write", status="new")

  k = 0
  DO i = 0, 9999
     IF (MOD(i*i,1000) == 444) THEN
        WRITE(12, *) i
        k = k + 1
     ENDIF
  ENDDO

  CLOSE(12)
  
  PRINT *, "to plithos einai", k
  
END PROGRAM ask
