Unfortunately both your solution doesn't work correctly.
I just need to know what it should return.
The number of variants or the number of occurrences of gwords.