How would I count the first line in 2/4?

2/4 is a time signature. Since it's in 2/4 time, the top number tells us that each note receives two beats in one measure and the bottom tells us which type of note, which is a quarter note.
For the first measure, it receives 2 beats since that's what a half note/rest equals to. The second measure has a quarter rest and a quarter note, which the two separately equals to a beat and the measure receives two beats.