/* */ //#pragma comment(linker, "/STACK:16777216") #define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define norm asdfasdgasdgsd #define eps 1e-9 #define M_PI 3.141592653589793 #define bs 666013 #define bsize 256 using namespace std; const int INF = 1e9; const int N = 100031; int n, m; int board[550][550]; int up[550][550]; int ans; int best_up; int main(){ //freopen("fabro.in","r",stdin); //freopen("fabro.out","w",stdout); //freopen("F:/in.txt", "r", stdin); //freopen("F:/output.txt", "w", stdout); ios_base::sync_with_stdio(0); //cin.tie(0); cin >> n >> m; string st; getline(cin, st); for (int i = 1; i <= n; i++) { string st; getline(cin, st); for (int j = 1; j <= m; j++) { if (st[j - 1] == '1') board[i][j] = 1; else board[i][j] = 0; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { up[i][j] = up[i - 1][j] + 1; if (board[i][j] == 0) up[i][j] = 0; } } for (int i = 1; i <= n; i++) { int best_up = -100000; for (int j = 1; j <= m; j++) { if (board[i][j] == 0) { best_up = -100000; continue; } if (up[i][j] > 1) { ans = max(ans, best_up + up[i][j]); best_up = max(best_up + 1, up[i][j]); } else best_up++; } } cout << ans << endl; cin.get(); cin.get(); return 0; }