#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Int = long long;
const Int INF=1e18;

int main(){
    int n,m;cin>>n>>m;
    map<int,pair<int,int>>list;

    rep(i,n){
        int x;cin>>x;
        list[x]=make_pair(1,0);
    }

    rep(i,m){
        int x;cin>>x;
        pair<int,int>y=make_pair(1,0);
        if(!list.count(x)){
            list[x]=make_pair(0,1);
        }
        else if(list[x]==y){
            list[x].second=1;
        }
    }

    pair<int,int>a,b;
    a=make_pair(1,0);
    b=make_pair(0,1);


    for(auto L:list){
        if(L.second==a||L.second==b){
            cout<<L.first<<" ";

        }
    }
    return 0;

    

    



}

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stdio.h>
#include<deque>
#include<map>
#include<queue>
#include<cmath>

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;


int main(){
    ll h,w;
    cin >> h >> w;

    vector<vector<int>> s(h);

    loop(i,h){
        loop(j,w){
            char c;
            cin >> c;
            if(c == '#') {
                s[i].push_back(1);
            }else{
                s[i].push_back(0);
            }
        }
    }

    ll ans = 0;

    loop(i, h - 1){
        loop(j, w - 1){
            int tmp = s[i][j] + s[i + 1][j] + s[i][j + 1] + s[i + 1][j + 1]; 
            if(tmp == 1 || tmp == 3) ans++;
        }
    }

    cout << ans << endl;
}