Source Code
#include <bits/stdc++.h>
using namespace std;

void solve()
{
int n, m;
cin>>n>>m;
char a[n][m];
for(int r=0;r<n;r++)
{
    for(int c=0;c<m;c++)
    {
        scanf(" %c",&a[r][c]);
    }
}
int counter=0;
for(int c=0;c<m;c++)
{
    int cnt=0;
    for(int r=0;r<n;r++)
    {
        if(a[r][c]=='1') cnt++;
    }
    if(cnt==1) counter++;
}
cout<<min(counter,n);
}

int main() {
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
	return 0;
}

Copy
Obada Discovers His Hearing Issues TATAKAE
GNU G++17
41 ms
1.9 MB
Wrong Answer