import java.util.Scanner; public class Main { static int H; static int W; static String[][] A; static int route = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); H = sc.nextInt(); W = sc.nextInt(); A = new String[H][W]; for(int h = 0; h < H; h++) { String str = sc.next(); for(int w = 0; w < W; w++) { A[h][w] = str.substring(w, w + 1); } } // for(int h = 0; h < H; h++) { // for(int w = 0; w < W; w++) { // System.out.print(A[h][w]); // if(w == W - 1) { // System.out.println(); // } // } // } rec(0, 0, 1); System.out.println(route); } static void rec(int x, int y, int jewelry) { // System.out.println("(" + x + "," + y + ")" + " jewelry=" + jewelry); // if(jewelry == 0) { // return; // } boolean isOk = true; if(x == W - 1 && y == H - 1 && jewelry >= 0) { route++; return; } int jewelry1 = jewelry; int jewelry2 = jewelry; // 右へ移動 if(x + 1 <= W - 1 && !A[y][x + 1].equals(("#"))) { if(A[y][x + 1].equals("o")) { jewelry1++; rec(x + 1, y, jewelry1); }else if(A[y][x + 1].equals("x")) { if(jewelry1 < 1) { isOk = false; // return; }else { jewelry1--; rec(x + 1, y, jewelry1); } } } // 下へ移動 if(y + 1 <= H - 1 && !A[y + 1][x].equals(("#"))) { if(A[y + 1][x].equals("o")) { jewelry2++; rec(x, y + 1, jewelry2); }else if(A[y + 1][x].equals("x")) { if(jewelry2 < 1) { isOk = false; // return; }else { jewelry2--; rec(x, y + 1, jewelry2); } } } if(isOk == false) { return; } } }