In a school activity, 1000 students are participating. There are 1000 lockers. The teacher asks the first student to go to each locker and open it. Then he asks the second student to go to every second locker and close it. The third student is asked to go to every third locker and open it if it is closed and vice versa. The fourth student does the same for every fourth locker and so on. After all 1000 students do the same, how many lockers will remain open?