#include <bits/stdc++.h>
using namespace std;
bool resma(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first > p2.first) {
    return true;
  } else if (p1.first == p2.first) {
    if (p1.second < p2.second)
      return true;
    else
      return false;
  } else
    return false;
}
void check(vector<pair<int, int>> v, int k) {
  map<pair<int, int>, int> m;
  for (int i = 0; i < v.size(); i++) m[v[i]]++;
  sort(v.begin(), v.end(), resma);
  pair<int, int> p1 = v[k - 1];
  int x = m[p1];
  cout << x;
}
int main() {
  vector<pair<int, int>> v;
  int n, k;
  cin >> n >> k;
  while (n--) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  check(v, k);
  cout << "\n";
  return 0;
}
