using System; using System.Collections.Generic; using static System.Console; using System.Linq; class yuki325 { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(int n) => Enumerable.Repeat(0, n).Select(_ => ReadLine()).ToArray(); static void Main() { var n = NN; var s = string.Concat(SList(n)); var key = 998244353; var dp = new long[s.Length][]; for (var i = 0; i < dp.Length; ++i) dp[i] = new long[3]; if (s[0] == 'd') dp[0][1] = 1; else if (s[0] == 'k') dp[0][2] = 1; else { dp[0][0] = 1; if (s[1] != 'd') dp[0][1] = 1; if (s[1] != 'k') dp[0][2] = 1; } for (var i = 1; i < dp.Length; ++i) { var prevsum = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % key; if (i % 2 == 0) { if (s[i] == 'd') dp[i][1] = prevsum; else if (s[i] == 'k') dp[i][2] = prevsum; else { dp[i][0] = dp[i - 1][0]; if (s[i + 1] != 'd') dp[i][1] = prevsum; if (s[i + 1] != 'k') dp[i][2] = prevsum; } } else { var prevdk = (dp[i - 1][1] + dp[i - 1][2]) % key; if (s[i] == 'd') dp[i][1] = prevdk; else if (s[i] == 'k') dp[i][2] = prevdk; else { dp[i][0] = prevsum; if (i + 1 == s.Length || s[i + 1] != 'd') dp[i][1] = prevdk; if (i + 1 == s.Length || s[i + 1] != 'k') dp[i][2] = prevdk; } } } //DebugTable(dp); WriteLine(dp[s.Length - 1].Sum() % key); } static void DebugTable(T[][] table) { Console.WriteLine("{"); foreach (var list in table) Console.WriteLine(string.Join(", ", list)); Console.WriteLine("}"); } }