Hey, thanks for your help.
I have posted my complete code.
The problem i am running into is to how to sum over rows, not columns. As long as column has "M" appearing once, I count it otherwise the count should be zero. However, I do care about if "M" appears in another row for the same name. So I have it sum it up.
Am I being clear enough? I am getting stuck with how to add over rows which somehow has to be out of the for loop (over columns) but I am not able to figure out how.