A school principal ordered 1,000 pencils. He gave an equal number to each of 7 teachers untill had given out as many as possibe. How many pencils were left?