#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
map<pair<long long, long long>, long long> m;
bool cmp(pair<long long, long long> p1, pair<long long, long long> p2) {
  if (p1.first == p2.first) return p1.second < p2.second;
  return p1.first > p2.first;
}
int main() {
  int x, y, n, i, j, k, l, b, a;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back({a, b});
    m[{a, b}]++;
  }
  sort(v.begin(), v.end(), cmp);
  cout << m[v[k - 1]];
}
