#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y));
#define chmax(x,y) x = max((x),(y));
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;
char maze[20][20];

int main(){
    int h,w;
    cin >> h >> w;
    rep(i,h)rep(j,w) cin >> maze[i][j];
    int ans = 0;
    rep(i,h)rep(j,w){
        if(maze[i][j] == '#') ans += 4;
    }
    rep(i,h-1)rep(j,w-1){
        int cnt = 0;
        if(maze[i][j] == '#') ++cnt;
        if(maze[i+1][j] == '#') ++cnt;
        if(maze[i][j+1] == '#') ++cnt;
        if(maze[i+1][j+1] == '#') ++cnt;
        if(cnt == 2) ans -= cnt;
        if(cnt == 4) ans -= cnt;
        if(cnt == 3) ans -= cnt-1;
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i64 i=0; i<n; i++)
#define all(v) v.begin(),v.end()
#define pp pair<int,int>
using Graph=vector<vector<int>>;
using i64=int64_t;

int main() {
    int si,sj;cin>>si>>sj;
    vector<vector<int>> t(50,vector<int>(50));
    rep(i,50) {
        rep(j,50) {
            cin>>t[i][j];
        }
    }
    vector<vector<int>> p(50,vector<int>(50));
    rep(i,50) {
        rep(j,50) {
            cin>>p[i][j];
        }
    }
    vector<char>ans;
    if(si<=48) {
        if(t[si][sj]!=t[si+1][sj]) {
            ans.push_back('D');
        } else {
            ans.push_back('U');
        }
    } else {
        if(sj<=48) {
            if(t[si][sj]!=t[si][sj+1]) {
                ans.push_back('R');
            } else {
                ans.push_back('L');
            }
        } else {
            if(t[si][sj]!=t[si][sj-1]) {
                ans.push_back('L');
            } else {
                ans.push_back('U');
            }
        }
    }
    rep(i,ans.size()) {
        cout << ans[i];
    }
}