/**
 * Created by IntelliJ IDEA.
 * User: o_215
 * Date: 21.10.2009
 * Time: 17:50:58
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import java.io.*;

public class E {
public static void main(String[] args) throws Exception{
    Scanner in=new Scanner(new File("floor.in"));
    PrintWriter out=new PrintWriter(new File("floor.out"));
    int n=in.nextInt();
    int m=in.nextInt();
    in.nextLine(); int count=n*m;
    String[] s=new String[n];
    s[0]=in.nextLine()+' ';
    for (int i=0;i<n-1;i++){
        s[i+1]=in.nextLine()+' ';
        for(int j=0;j<m;j++){
            if ((s[i].charAt(j)=='-' && s[i].charAt(j+1)=='-')
              ||(s[i].charAt(j)=='|' && s[i+1].charAt(j)=='|')){
                count--;
            }
        }
    }
    for(int j=0;j<m;j++){
        if (s[n-1].charAt(j)=='-' && s[n-1].charAt(j+1)=='-'){
            count--;
        }
    }

    out.println(count);
    in.close();
    out.close();
}
}
