#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long, long long> p, pair<long long, long long> p2) {
  if (p.first == p2.first) {
    if (p.second > p2.second) {
      return 1;
    } else {
      return 0;
    }
  } else {
    return p.first < p2.first;
  }
}
vector<pair<long long, long long>> vec;
map<pair<long long, long long>, long long> occ;
long long i, j;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k, sco, pen, cnt = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> sco >> pen;
    vec.push_back({sco, pen});
    occ[vec[i]]++;
  }
  sort(vec.rbegin(), vec.rend(), cmp);
  cout << occ[vec[k - 1]];
}
