#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m, x1, x2, x3 = 0;
cin >> n >> m;
//cout << n << m << ' ' << endl;
for(int i = 1; i<=n; i++){
cin >> x1;
//cout << x1 << x2;
for(int j = 1; j <= m; j++){
cin >> x2;
if(m == i){
for(int b = x1 - 1; b >= 1; b--){
if(){
x3 += x1;
}
}
}
}
}
cout << x3;
return 0;
}