#include #include using namespace std; int main() { int r,c; char* row; cin >> r; cin >> c; if(r < 1 || c < 1) { cout << 0 << endl; return 0; } char num; int count = 0; for(int i = 0; i < r; i++) { if(!(i % 2)) { for(int j = 0; j < c; j++) { cin >> num; if(!(j % 2)) { count += num-48; } } } else { for(int j = 0; j < c; j++) { cin >> num; if(j % 2) { count += num-48; } } } } /*for(int i = 0; i < r; i++) { row = new char[c]; for(int j = 0; j < c; j++) { row[j] = 0; } cin >> row; if(cin.eof()) { break; } for(int k = 0; k < c; k++) { count += row[k] - 48; } delete row; }*/ cout << count << endl; return 0; }