#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long X;
    cin >> N >> X;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    long long ans = X;
    for(int i = 1; i <= N; i++){
        vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>> (i + 1, vector<long long>(i, -1)));
        dp[0][0][0] = 0;
        for(int j = 0; j < N; j++){
            for(int k = 0; k <= i; k++){
                for(int l = 0; l < i; l++){
                    if(k == i){
                        dp[j + 1][k][l] = max(dp[j + 1][k][l], dp[j][k][l]);
                        continue;
                    }
                    if(dp[j][k][l] == -1) continue;
                    dp[j + 1][k + 1][(l + A[j]) % i] = max(dp[j + 1][k + 1][(l + A[j]) % i], dp[j][k][l] + A[j]);
                    dp[j + 1][k][l] = max(dp[j + 1][k][l], dp[j][k][l]);
                }
            }
        }
        int ind = X % i;
        if(dp[N][i][ind] == -1) continue;
        long long t = (X - dp[N][i][ind]) / i;
        ans = min(ans, t);
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define            pb            push_back
#define            pl            pair<ll,ll>
#define            pll           pair<ll,pair<ll,ll>>
#define            ll            long long
#define            vl            vector<ll>
#define            fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define            mp            make_pair
#define            w(t)          int t;cin>>t;while(t--)
#define            inf           1e18
#define            fi(a,n)       for(ll i=a;i<n;i++)
#define            fr(i,a,b)     for(ll i=a;i>=b;i--)
#define            fj(a,n)       for(ll j=a;j<n;j++)
#define            k(a,n)        for(ll k=a;k<n;k++)
#define            endl          "\n"
#define            all(v)        (v).begin(),(v).end()
#define            set1(x)       __builtin_popcount(x)
#define            gcd(a,b)      __gcd(a,b)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
using namespace std;
const ll mod= 1000000007;
const ll N =1000005;
void solve()
{
   ll h,w;
   cin>>h>>w;
   ll a[h][w];
   fi(0,h)
   {
    fj(0,w)
    {
      char k;
      cin>>k;
      if(k=='#')
        a[i][j]=1;
      else
        a[i][j]=0;
    }
   }



   ll ans=0;


   fi(0,h-1)
   {
    fj(0,w-1)
    {
      ll s=a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1];
      if(s&1)
      {
        ans+=1;
      }
    }
   }
   cout<<ans<<endl;
}
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
     // w(t)
      solve();

}