#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int main() {
  int n, k;
  int i;
  while (cin >> n >> k) {
    vector<pair<int, int> > v;
    int score, time;
    int count;
    count = 0;
    for (i = 0; i < n; i++) {
      cin >> score >> time;
      v.push_back(pair<int, int>(score, time));
    }
    sort(v.begin(), v.end(), cmp);
    for (i = 0; i < n; i++) {
      if (v[i].first == v[k - 1].first && v[i].second == v[k - 1].second)
        count++;
    }
    cout << count << endl;
  }
  return 0;
}
