Distance between two notes
An interval is the pitch relationship between two notes. Notes played in sequence form a melodic interval; notes played together form a harmonic interval. Adjacent piano keys are one semitone apart, and two semitones make a whole tone. From C, C♯ is one semitone away, D is two, E♭ is three and E is four.
The same interval from another note
C to G and E to B are both seven semitones, or perfect fifths. Moving the starting note changes the keys but preserves the interval. The name communicates the relationship more clearly than counting keys every time.
Interval names and symbols
The number counts note letters including both endpoints: C–E is a third; C–G is a fifth. Major uses M and perfect uses P. C–D is M2, C–E is M3, C–F is P4, C–G is P5, C–A is M6, C–B is M7 and C–the next C is P8. The same C key is a perfect unison, P1.
For these natural-note examples from C, seconds, thirds, sixths and sevenths are major; unisons, fourths, fifths and octaves are perfect. Accidents and other roots change the quality, so always check the spelling and semitone distance.