#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  {
    if (a.first != b.first) {
      return (a.first > b.first);
    } else {
      return (a.second < b.second);
    }
  }
}
int main() {
  int n, x, a, b;
  cin >> n >> x;
  vector<pair<int, int>> vect;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    vect.push_back(make_pair(a, b));
  }
  sort(vect.begin(), vect.end(), sortbysec);
  cout << count(vect.begin(), vect.end(), vect[x - 1]);
  return 0;
}
