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

int main(){
    int H,W;
    cin >> H >> W;
    int block_min=101;
    int block_grid=0;
    int block_mins=0;
    vector<int> A(W);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[j];
            int a=A[j];
            if(a<block_min){
                block_min=a;
            }
        }
        if(block_min<block_mins){
            block_grid+=W*i*(block_mins-block_min);
        }
        for(int k=0;k<W;k++){
            block_grid+=A[k]-block_min;
        }
        block_mins=block_min;
    }
    cout << block_grid << endl;
}
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    cin>>a>>b;
    int ans = 2*a+100;
    ans-=b;
    cout<<ans;

    return 0;
}