#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
typedef long long ll;

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> a(n),cnt(n,0);
    rep(i,n) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    int sum=0,nk=k;
    for(int i=0;i<=n;i++) {
        nk=min(nk,cnt[i]);
        sum+=nk;
    } 
    cout << sum << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
int main() {
	FASTIO

	int t = 1;
//	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vpii v(n);
		fo(i, n) {
			cin>>v[i].F;
            cin>>v[i].S;
		}
		int ans = 0;
		fo(i, n) {
			int x1 = v[i].F;
			int y1 = v[i].S;
          //  cout<<x1<<" "<<y1<<"points"<<endl;
			for (int j = i + 1; j < n; j++) {
				int delx=v[j].F-x1;
				int dely=v[j].S-y1;
            //    cout<<delx<<" "<<dely<<endl;
				if ( abs(dely)<=abs(delx) ) {
					ans++;
				}
            }
		}
		cout << ans << endl;
	}

	return 0;
}
