Key signatures are important when reading music. You must understand how to read key signatures in order to know how to play the notes the way the composer intended. The key signature is a grouping of symbols (sharps [#] and flats [b]) that tell you to always play certain notes one semitone (half-step) higher or lower. The key signature is typically placed after the clef at the beginning of the music or after a double bar.
To better understand how to read key signatures, take another look at the circle of fifths.
To figure out how many sharps are in each key signature, count clockwise on the Circle of Fifths from C major. The number of sharps in each successive key goes up by one in that key’s key signature. So, if there is one sharp in the key signature, then move one “stop” from C Major, which gets you to G major (or e minor); if there are two sharps in the key signature, move two stops away from C, landing you at D major (or b minor). Therefore, to play a song in the key of B major — five stops away from C major on the circle — you know there will be five sharps in that key.
Therefore, to play a song in the key of B major — five stops away from C major on the circle of fifths — you know there will be five sharps in that key. Sharps appear in a specific order as you go around the Circle clockwise: F#, C#, G#, D#, A#, E#, and B# (remember: Fat Cats Go Down Alleys Eating Birds).
For major scales that have flats, you go counter-clockwise around the circle of fifths. The flats appear in a specific order in every key as you go around the circle counter-clockwise: Bb, Eb, Ab, Db, Gb, Cb, and Fb (remember: Battle Ends, And Down Goes Charles’ Father). Therefore, if the key signature shows one flat (Bb), you would move counter-clockwise one stop away from C major, landing you at F major (or d minor).
So, for example, Gb, which is six steps away from C major on the circle, has six flats in its key signature. Recalling your mnemonic (Battle Ends, And Down Goes Charles's Father), you know that those flats are Bb, Eb, Ab, Db, Gb, and Cb. Bb major, which is two steps away, has two flats, and now you know those flats have to be Bb and Eb.