#include <bits/stdc++.h>

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll m[100][100];

void show_table(ll I, ll J) {
  for (ll i = 0; i <= I; i++) {
    for (ll j = 0; j <= J; j++) {
      cout << m[i][j] << " ";
    }
    cout << "" << endl;
  }
  cout << "" << endl;
}

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W;
  scanf("%lld %lld", &H, &W);

  for (ll y = 0; y < H; y++) {
    for (ll x = 0; x < W; x++) {
      m[y][x] = -1;
    }
  }

  ll spaces = 0;

  for (ll y = 0; y < H; y++) {
    string s;
    cin >> s;

    for (ll x = 0; x < W; x++) {
      if (s[x] == '.') {
        m[y][x] = INF;
        spaces++;
      }
    }
  }

  queue<pll> q;
  q.push(make_pair(0, 0));
  m[0][0] = 0;

  for (;;) {
    if (q.empty()) {
      break;
    }
    auto pos = q.front();
    ll y = pos.first;
    ll x = pos.second;

    ll c = m[y][x];

    if (y >= 1 && m[y - 1][x] > c + 1) {
      m[y - 1][x] = c + 1;
      q.push(make_pair(y - 1, x));
    }
    if (y < H - 1 && m[y + 1][x] > c + 1) {
      m[y + 1][x] = c + 1;
      q.push(make_pair(y + 1, x));
    }
    if (x >= 1 && m[y][x - 1] > c + 1) {
      m[y][x - 1] = c + 1;
      q.push(make_pair(y, x - 1));
    }
    if (x < W - 1 && m[y][x + 1] > c + 1) {
      m[y][x + 1] = c + 1;
      q.push(make_pair(y, x + 1));
    }

    q.pop();
  }

  // show_table(3, 3);

  ll a = m[H - 1][W - 1];

  if (a == INF) {
    cout << -1 << endl;
    return 0;
  }
  // cout << "a:" << a << endl;

  ll ans = spaces - a - 1;

  cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll h,w; cin>>h>>w;
    char s[h][w];
    rep(i,h)rep(j,w) cin>>s[i][j];

    ll di[]={1,0,-1,0},dj[]={0,1,0,-1};
    bool ok=true;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.') continue;
            bool ok2=false;
            rep(k,4){
                ll ni=i+di[k],nj=j+dj[k];
                if(ni<0||h<=ni||nj<0||w<=nj) continue;
                if(s[i][j]=='#' && s[ni][nj]=='#') ok2=true;
            }
            if(!ok2){
                ok=false;
                break;
            }
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}