The correct answer is "couldn't".
When I first came to Madrid, I couldn't speak only a few words of Spanish.
**Translation:**
Когда я впервые приехал в Мадрид, я не мог говорить даже несколько слов по-испански.
**Explanation:**
* "Could" implies ability, but the sentence needs a negative to make sense with "only a few words".
* "Couldn't" means "was not able to" which fits the context of learning a new language.
* "Have" doesn't fit the grammatical structure of the sentence.