Code:
if(input[aa]='a'|'d'|'g'|'j'|'m'|'p'|'s'|'w')
I only read that dubious line and didn't even bother going further ahead. You need that to be broken into multiple conditions. Or'ing those together is not at all doing what you want.