#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
#define chmax(a,b) if (a<b)a=b;
#define doublecout(a) cout<<setprecision(16)<<a<<endl;
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL; 
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}


ll n,x;

int main(){
  ll ans=llMAX;
  cin >> n >> x;
  vi a(n),b(n);
  REP(i,n) cin>>a[i];


  for(ll maini=1;maini<=n;maini++){

        vvi data(100, vi(maini,-1));  // N * M の2次元配列 N-1個つかって余りがMのやつを保存
        for(ll iii=0;iii<n;iii++){
          ll ta=a[iii];
          for(ll i=iii-1;i>=0;i--){
            for(ll j=0;j<maini;j++){
              if (data[i][j]==-1)continue;
              chmax(data[i+1][(j+ta)%maini],data[i][j]+ta)
            }
          }
          chmax(data[0][ta%maini],ta)
        }

        ll ax=x%maini;
        ll syokiti=data[maini-1][ax];
        if (syokiti==-1)continue;
        ans=min((x-syokiti)/maini,ans);
  }


  cout<<ans<<endl;
  return 0;
}

/*
10 22000
10 20 30 40 50 60 70 80 90 100
*/
#include <bits/stdc++.h>
using namespace std;
int _ = (cout << fixed << setprecision(9), cin.tie(0), ios::sync_with_stdio(0));
using Int = long long;
enum { ROW, COL };
int main() {
    int H, W; cin >> H >> W;
    vector<string> S(H); for (auto &s : S) cin >> s;
    vector<int> rows(H), cols(W);
    vector<vector<int>> rows_floor(H), cols_floor(W);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                rows_floor[i].push_back(j);
                cols_floor[j].push_back(i);
            }
        }
    }
    int nrow = H, ncol = W;
    auto rec = [&](auto&& rec, int type, int idx) -> void {
        if (type == ROW) {
            if (rows[idx]) return;
            rows[idx] = 1;
            nrow--;
            for (auto t : rows_floor[idx]) rec(rec, COL, t);
        } else {
            if (cols[idx]) return;
            cols[idx] = 1;
            ncol--;
            for (auto t : cols_floor[idx]) rec(rec, ROW, t);
        }
    };
    rec(rec, ROW, 0);
    rec(rec, ROW, H - 1);
    rec(rec, COL, 0);
    rec(rec, COL, W - 1);
    int ans = 0;
    for (int i = 0; i < H; i++) {
        if (!rows[i] && !rows_floor[i].empty()) {
            ans++;
            rec(rec, ROW, i);
        }
    }
    for (int i = 0; i < W; i++) {
        if (!cols[i] && !cols_floor[i].empty()) {
            ans++;
            rec(rec, COL, i);
        }
    }
    ans += min(nrow, ncol);
    cout << ans << '\n';
    return 0;
}