import java.util.*;
import java.io.*;
/**
 * Created by IntelliJ IDEA.
 * User: m09cke
 * Date: 21.10.2009
 * Time: 17:10:40
 * To change this template use File | Settings | File Templates.
 */
public class Main {
    public static void main(String[] args)throws FileNotFoundException{
        Scanner in = new Scanner(new File("floor.in"));
        PrintWriter out = new PrintWriter("floor.out");
        int n=in.nextInt();
        int m=in.nextInt();
        char floor[][]=new char[n][m];
        for (int i=0;i<n;i++){
            floor[i]=in.next().toCharArray();
        }
        boolean[][] bool=new boolean[n+2][m+2];
        for (int i=0;i<n+2;i++){
            for (int j=0;j<m+2;j++){
                bool[i][j]=false;
            }
        }
        int k=0;
        for (int i=0;i<n;i++){
            for (int j=0;j<m;j++){
                if (floor[i][j]=='|'){
                    if ((bool[i][j+1]==true&&floor[i-1][j]=='|')||(bool[i+2][j+1]==true&&floor[i+1][j]=='|')) {bool[i+1][j+1]=true;}
                    else {bool[i+1][j+1]=true;k++;}
                }
                else{
                    if ((bool[i+1][j]==true&&floor[i][j-1]=='-')||(bool[i+1][j+2]==true&&floor[i][j+1]=='-')) {bool[i+1][j+1]=true;}
                    else {bool[i+1][j+1]=true;k++;}
                }
            }
        }
        out.print(k);
        out.close();
    }
}