#include <bits/stdc++.h>
using namespace std;
class _166A {
 public:
  static 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;
  }
  void solve() {
    int n, k, i, j, ct = 0;
    cin >> n >> k;
    vector<pair<int, int>> a(n);
    map<pair<int, int>, int> mp;
    for (i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      a[i] = {x, y};
      mp[{x, y}]++;
    }
    sort(a.begin(), a.end(), cmp);
    i = k - 1;
    while (a[i].first == a[k - 1].first and a[i].second == a[k - 1].second and
           i >= 0)
      --i, ct++;
    i = k;
    while (a[i].first == a[k - 1].first and a[i].second == a[k - 1].second and
           i < n)
      i++, ct++;
    cout << mp[a[k - 1]];
  }
};
int main() {
  _166A ob;
  ob.solve();
  return 0;
}
