Sometimes a song does not begin on the first beat of the bar. Any notes which come before the first full bar are called lead-in notes (or pick-up notes). When lead-in notes are used, the last bar is also incomplete. The notes in the lead-in and the notes in the last bar add up to one full bar. Here is an example.
As well as the use of lead-ins, another common variation to the number of bars in written music is the use of first and second endings. The first time you play through the song, play the first ending, (Z), then go back to the beginning.
The second time you play through the song, play the second ending (X ) instead of the first. This saves a lot of space when everything played the second time is an exact repeat of the first time except for the final bar(s). First and second endings may be used at the end of a song, or at the end of a verse or section.