The second poster is incorrect. They are calculated using your second option, A for 4 credits and F for 4 credits(total of 8 credits).
On page 15 of the link provided above, it states "AMCAS counts all attempts of a repeated course, even if your school does not"
It also states that "Grades and credit hours for all failed courses will be included in the AMCAS GPA, even if they are not included in the GPA calculations of the transcript-issuing institution"
For DO schools it is different, they only take the top grade for the class you took. For their application you would have an A for 4 credits.