Circle of fifths
The flats work in exactly the opposite way.  Instead of going up to the fifth note (e.g. C,D,E,F,G) we can go down a fifth (C,B,A,G,F).  F is the scale which has one flat.  As we get flatter and flatter we go counter-clockwise round the circle until all seven notes are flattened.