#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)

const int mod = 1e9+7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];

  vector<vector<vector<modint>>> dp(3,vector<vector<modint>>(h,vector<modint>(w,0)));
  int dh[3] = {1,1,0};
  int dw[3] = {0,1,1};
  rep(i,3) if(s[dh[i]][dw[i]]!='#')dp[i][dh[i]][dw[i]] = 1;

  rep(hi,h)rep(wj,w){
    rep(k,3){//どの方向に進むか    
      int nh = hi+dh[k];
      int nw = wj+dw[k];
      if(nh<0 || nw <0 || nh>=h || nw>=w) continue;
      if(s[nh][nw]=='#') continue;
      rep(m,3){//今どの状態か
        if(m==k) dp[k][nh][nw]  += dp[m][hi][wj]*((modint) 2);
        else dp[k][nh][nw] += dp[m][hi][wj];
      }
    }
  }
  // rep(k,3){
  // rep(i,h)rep(j,w){
  //   cout << dp[k][i][j] << " \n"[j==w-1];
  // }
  // cout << endl;
  // }
  modint ans = 0;
  rep(i,3) ans += dp[i][h-1][w-1];
  cout << ans << endl;

  
  return 0;
    

}

#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define all(x)         x.begin(),x.end()
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
inline void solve() {
    int b, c;
    cin >> b >> c;
    int ans = 0;
    if (c > 2) {
        if (b > 0) {
            ans += (((c - 1) / 2) * 2 + 1 + 1);
            if ((c - 1) % 2 == 0) {
                ans--;
            }
        }
        else if (b <= 0) {
            ans += ((c / 2) + 1) * 2;
            if (c % 2 == 0) {
                ans--;
            }
        }
    }
    else {
        ans = 2;
    }

    if (b == 0) {
        ans--;
    }

    // db(ans);

    if (b > 0 and c > 1) {
        int cnt = (c / 2) * 2;
        if (c % 2 == 0) {
            cnt--;
        }
        int option2 = 2 * b - 1;
        ans += min(cnt, option2);
    }
    else if (b<0 and c>1) {
        c--;
        int cnt = (c / 2) * 2;
        if (c % 2 == 0) {
            cnt--;
        }
        int option2 = 2 * abs(b) - 1;
        ans += min(cnt, option2);
    }
    cout << ans << endl;
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}