#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF  = 1e9;
constexpr llong  LINF = 1e18;
constexpr double EPS  = 1e-12;
constexpr int    MOD  = 1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a)cerr<<(cnt++?' ':'>')<<elem;cerr<<endl;}

using vl   = vector<long long>;
using vvl  = vector<vl >;
using vvvl = vector<vvl >;
using pll  = pair<long long,long long>;

int main(){
	int n;
	cin>>n;
	
	vl cnt(200,0);
	REP(i,n){
		llong a;
		cin>>a;
		
		cnt[a%200]++;
	}
	
	llong ans=0;
	REP(i,200){
		ans+=cnt[i]*(cnt[i]-1)/2;
	}
	
	cout<<ans<<endl;
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<pair<ll,ll>> friends(n);
  for(int i=0;i<n;i++){
    ll a,b;
    cin >> a >> b;
    friends[i] = make_pair(a,b);
  }

  sort(friends.begin(), friends.end());

  ll place = 0;
  int vn = 0;
  while(k > 0){
    place += k;
    k = 0;

    for(int i=vn;i<n;i++){
      if(friends[i].first <= place){
        k += friends[i].second;
        vn = i+1;
      }else{
        break;
      }
    }
  }

  cout << place << endl;
}