The circle of fifths
Move around the circle of fifths, finding neighbouring keys and counting the key signature.
Sharps: up in fifths
Going up from C major in perfect fifths, each key gets one more sharp:
Major C G D A E B F♯ C♯
Sharps 0 1 2 3 4 5 6 7
Sharps appear in a fixed order: F, C, G, D, A, E, B, also in fifths. The last sharp is degree VII of the major key: the tonic is a semitone above it.
Three sharps, F, C and G: A major (or F♯ minor)
Practice: How many sharps?
Flats: down in fifths
Going down in fifths from C major, each key gets one more flat: F (1), B♭ (2), E♭ (3), A♭ (4), D♭ (5), G♭ (6), C♭ (7).
The order of flats is the order of sharps reversed: B, E, A, D, G, C, F. The second-to-last flat is the tonic of the major key.
So the keys close into a circle. Neighbours on the circle differ by one sign: they are closely related keys.
Three flats, B, E and A: E♭ major (or C minor)
Minor keys sit on the circle next to their relative majors: A minor by C major, E minor by G major. They have the same number of signs.