import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int h = sc.nextInt(); int w = sc.nextInt(); char[][] field = new char[h][]; List>> dp = new ArrayList<>(); for (int i = 0; i < h; i++) { field[i] = sc.next().toCharArray(); dp.add(new ArrayList<>()); for (int j = 0; j < w; j++) { dp.get(i).add(new HashMap<>()); } } dp.get(0).get(0).put(1, 1); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if ((i == 0 && j == 0) || field[i][j] == '#') { continue; } if (i > 0) { for (Map.Entry entry : dp.get(i - 1).get(j).entrySet()) { int key = entry.getKey(); int value = entry.getValue(); if (field[i][j] == 'o') { dp.get(i).get(j).put(key + 1, dp.get(i).get(j).getOrDefault(key + 1, 0) + value); } else if (key > 0) { dp.get(i).get(j).put(key - 1, dp.get(i).get(j).getOrDefault(key - 1, 0) + value); } } } if (j > 0) { for (Map.Entry entry : dp.get(i).get(j - 1).entrySet()) { int key = entry.getKey(); int value = entry.getValue(); if (field[i][j] == 'o') { dp.get(i).get(j).put(key + 1, dp.get(i).get(j).getOrDefault(key + 1, 0) + value); } else if (key > 0) { dp.get(i).get(j).put(key - 1, dp.get(i).get(j).getOrDefault(key - 1, 0) + value); } } } } } long ans = 0; for (int x : dp.get(h - 1).get(w - 1).values()) { ans += x; } System.out.println(ans); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }