#include <bits/stdc++.h> //Header Files

#define ll long long int
#define mod 1000000007
#define endl "\n"

using namespace std;

template <class T>
void out(int t, T ans)
{
    cout << "Case #" << t << ": " << ans << endl;
}

template <class T>
void out(int t, T ans[])
{
    cout << "Case #" << t << ": ";
    for (T val : ans)
        cout << val << " ";
    cout << endl;
}

template <class T>
void out(int t, vector<T> &ans)
{
    cout << "Case #" << t << ": ";
    for (T val : ans)
        cout << val << " ";
    cout << endl;
}

void runTest(int o)
{
    // Start coding here ...
    int h, w;
    cin >> h >> w;

    int mini = INT_MAX;
    int a[h][w];

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
            mini = min(mini, a[i][j]);
        }

    ll sum = 0;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            sum += a[i][j] - mini;
        }

    cout << sum << endl;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; i++)
        runTest(i + 1);

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define print(v,n) for(i=0;i<n;i++) cout<<v[i]<<" ";
#define No cout<<"NO"<<endl;return
#define Yes cout<<"YES"<<endl;return
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
#define PI 3.14159265   ;
ll mod =1e9+7;
bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i*i <= n; i = i + 6)
        if (n%i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll powe(ll x, ll y) {
    ll res = 1;
    while (y > 0) {
        if (y & 1) res =( res * x)%mod;
        y = y >> 1;
        x = (x * x)%mod;
    }
    return res;
}
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
unsigned long long power(unsigned long long x, int y, int p)
{
    unsigned long long res = 1; // Initialize result
 
    x = x % p; // Update x if it is more than or
    while (y > 0) 
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n,int p)
{
    return power(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n,int r, int p)
{
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
    unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;
 
    return (fac[n] * modInverse(fac[r], p) % p
            * modInverse(fac[n - r], p) % p)
           % p;
}

void solve()
{
    ll i, x, y, j, k4, h, n, w, k1, k2,k3,q;
    cin>>n>>x;
    vll v;
    f(i,0,n)
    {
        cin>>j;
        if(j!=x) v.pb(j);
    }
    f(i,0,v.size()) cout<<v[i]<<" ";
}

int main() {
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin); 
        freopen("output.txt", "w", stdout); 
    #endif
    fast;
    ll i, j, l, k, t, n;
    t=1;
    //cout<<0;
    for (i = 1; i <= t; i++)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
    }
}
// 