#include <bits/stdc++.h>
using namespace std;
bool check(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first)
    return a.second < b.second;
  else
    return false;
}
int main() {
  int n, k;
  cin >> n >> k;
  pair<int, int> a[n];
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; i++) {
    int p, t;
    cin >> p >> t;
    a[i] = make_pair(p, t);
    mp[a[i]]++;
  }
  sort(a, a + n, check);
  cout << mp[a[k - 1]] << "\n";
  return 0;
}
