#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b #define vl vector #define vii vector> #define vll vector> #define vvi vector> #define vvl vector> #define vvii vector>> #define vvll vector>> #define vst vector #define pii pair #define pll pair #define pb push_back #define all(x) (x).begin(),(x).end() #define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end()) #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=15<<26; map MA[13][13]; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int H,W;cin>>H>>W; vst S(H); for(int i=0;i>S[i]; } vvi can(H,vi(W,-1)); for(int i=0;i=H||w<0||w>=W) continue; if(S[h][w]=='#') cn++; } } if(cn>=2) can[i][j]=1; else can[i][j]=0; } //cout<=2) nsc++; } if(w>=2){ if(nT&(1<<(w-2))){ nT^=(1<<(w-2)); } } chmax(MA[h][w+1][nT],nsc); } if(can[h][w]==0||can[h][w]==1){ int nsc=sc,nT=T; nT|=(1<<(2*W+w)); if(h&&w&&can[h-1][w-1]==1&&(!(nT&(1<<(W+w-1))))){ int cn=0; for(int dh=h-2;dh<=h;dh++){ for(int dw=w-2;dw<=w;dw++){ if(dh<0||dw<0) continue; if(nT&(1<<((dh-(h-2))*W+dw))) cn++; } } if(cn>=2) nsc++; } if(w>=2){ if(nT&(1<<(w-2))){ nT^=(1<<(w-2)); } } chmax(MA[h][w+1][nT],nsc); } } } for(auto [T,sc]:MA[h][W]){ int nsc=sc,nT=T; //cout<=2) nsc++; } chmax(MA[h+1][0][nT>>W],nsc); } } int res=0; for(auto [T,sc]:MA[H][0]){ int nsc=sc-100,nT=T; for(int w=0;w=W) continue; if(nT&(1<<((dh-(H-2))*W+dw))) cn++; } } if(cn>=2) nsc++; } } chmax(res,nsc); } cout<