Count letters before semitones
An interval name has a number and a quality. The number follows the letter names: C–E, C–E♭, C–E♯ and C–E𝄫 are all thirds. Accidentals change their widths, not their letter count.
Four kinds of third
C–E𝄫 spans two semitones and is a diminished third (d3). C–E♭ spans three and is a minor third (m3). C–E spans four and is a major third (M3). C–E♯ spans five and is an augmented third (A3). A major interval narrowed by one semitone becomes minor; narrowed once more, diminished. Widened by one semitone, it becomes augmented.
Perfect interval families
C–G is a perfect fifth (P5) at seven semitones. C–G♭ is a diminished fifth (d5) at six; C–G♯ is an augmented fifth (A5) at eight. Fifths belong to the perfect family, so there is no major or minor fifth.
The same keys can have different names
C–E♯ is an augmented third and C–F is a perfect fourth. Both sound five semitones apart because E♯ and F share a piano key. The written note name determines the interval spelling; sound or keyboard position alone cannot distinguish them.