import java.util.*;
import java.io.*;

   public class zadacha {
        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();
            int kol=n*m;
            int [][] a=new int [n][m];
            int i;
            int j;
            for (i=0; i<n; i++)
            {
                String s=in.next();
                for (j=0; j<m; j++)
                {
                a[i][j]=s.charAt(j);
                }
            }
            for (i=0; i<n; i++)
            {
                for (j=0; j<m; j++)
                {
                    if ( ( i < n - 1 && (a[i][j]==a[i+1][j]&&a[i][j]=='|') )
                       ||( j < m - 1 && (a[i][j]==a[i][j+1]&&a[i][j]=='-') ) )
                    {
                        //out.println(i + " " + j);
                        kol--;
                    }
                }
            }
            out.println(kol);

            out.close ();
   }
   }


