#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
const int MOD=1e9+7;

void solve()
{
        int h,w;
        cin>>h>>w;
        char a[1+h][1+w];
        for(int i=1;i<=h;i++)
        {
                for(int j=1;j<=w;j++)
                        cin>>a[i][j];
        }
        int count=0;
        for(int i=2;i<=h;i++)
        {
                for(int j=1;j<=w;j++)
                {
                        if(a[i][j]=='#')
                        {
                                int len=0;
                                while(j<=w && a[i][j]=='#' && a[i-1][j]=='.')
                                {
                                        len++;
                                        j++;
                                }
                                if(len>0)
                                        count++;
                        }
                }
        }
        for(int i=1;i<=h-1;i++)
        {
                for(int j=1;j<=w;j++)
                {
                        if(a[i][j]=='#')
                        {
                                int len=0;
                                while(j<=w && a[i][j]=='#' && a[i+1][j]=='.')
                                {
                                        len++;
                                        j++;
                                }
                                if(len>0)
                                        count++;
                        }
                }
        }
        for(int j=2;j<=w;j++)
        {
                for(int i=1;i<=h;i++)
                {
                        if(a[i][j]=='#')
                        {
                                int len=0;
                                while(i<=h && a[i][j]=='#' && a[i][j-1]=='.')
                                {
                                        len++;
                                        i++;
                                }
                                if(len>0)
                                        count++;
                        }
                }
        }
        for(int j=1;j<=w-1;j++)
        {
                for(int i=1;i<=h;i++)
                {
                        if(a[i][j]=='#')
                        {
                                int len=0;
                                while(i<=h && a[i][j]=='#' && a[i][j+1]=='.')
                                {
                                        len++;
                                        i++;
                                }
                                if(len>0)
                                        count++;
                        }
                }
        }
        cout<<count<<endl;
}
int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
                solve();
        return 0;
}


#include <stdio.h>
#define M 5000
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#include <math.h>
#define vi v(n) vector<ll> v(n);
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll fact[200005];
ll invfact[200005];
const ll N=200005;
const ll MOD=998244353;
ll Power(ll base , ll e)
{
    if(e == 0) return 1;
    ll ans = base; e--;
    while(e)
  {
        if(e & 1) ans = (((ans%MOD) * (base%MOD)) %MOD+MOD)%MOD;
        base = (((base%MOD) * (base%MOD)) %MOD+MOD)%MOD;
        e >>= 1;
  }
  return (ans+MOD) %MOD;
}

ll modinv(ll k)
    {
        return Power(k, MOD-2);
    }

void precompute()
    {
        fact[0]=fact[1]=1;
        for(ll i=2;i<N;i++)
        {
            fact[i]=fact[i-1]*i;
            fact[i]%=MOD;
        }
        invfact[N-1]=modinv(fact[N-1]);
        for(ll i=N-2;i>=0;i--)
        {
            invfact[i]=invfact[i+1]*(i+1);
            invfact[i]%=MOD;
        }
    }

    ll nCr(ll x, ll y)
    {
        if(y>x)
            return 0;
        ll num=fact[x];
        num*=invfact[y];
        num%=MOD;
        num*=invfact[x-y];
        num%=MOD;
        return num;
    }



int main(){
ll n,m;
cin>>n>>m;
vector<ll> dp(m+1,0);
ll times=2;
precompute();
ll ans=0;
fo(i,m){
    ans++;
    dp[i+1]=1;
}
bool ok=true;
while(ok&&times<=n){
    ok=false;
    vector<ll> dp2(m+1,0);
    fo(i,m+1) dp2[i]=0;
    FOR(i,1,m){
        for(int j=i+i;j<=m;j=j+i){
            if(dp[i]){
            dp2[j]+=dp[i];
            ok=true;
            }
        }
    }
   // dbg3(times,accumulate(all(dp2),0),nCr(n-1,times-1));
    ll val=(accumulate(all(dp2),0))%MOD;
    val=((val%MOD)*(nCr(n-1,times-1)%MOD))%MOD;
    ans=(ans+val)%MOD;
    dp=dp2;
    times++;
}
cout<<ans<<endl;


}
