from collections import defaultdict MOD = 998244353 N,M = list(map(int,input().split())) S = input() all_hatena = S.count("?") edge = defaultdict(list) for _ in range(M): a,b = list(map(int,input().split())) a -= 1;b -= 1 edge[a].append(b) edge[b].append(a) hatena_count = 0 def f(n,depth): global hatena_count if(depth == 3):return 26**(all_hatena - hatena_count) ret = 0 for i in edge[n]: if(i in visited):continue if("aoi"[depth] != S[i] and S[i] != "?"):continue if(S[i] == "?"):hatena_count += 1 visited.add(i) ret += f(i,depth+1) visited.remove(i) if(S[i] == "?"):hatena_count -= 1 return ret ans = 0 for i in range(N): if(S[i] == "a" or S[i] == "?"): hatena_count = 0 if S[i] != "?" else 1 visited = set() visited.add(i) ans += f(i,1) print(ans)