In a story-writing contest, Gemma and Megan wrote a total of 5384 words. Megan wrote 386 words less than Gemma. How many words did Gemma write?