#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[111111], x;
int n, k, ans;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first > b.first;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int cnt, t;
    cin >> cnt >> t;
    p[i] = make_pair(cnt, t);
  }
  sort(p + 1, p + 1 + n, cmp);
  x = p[k];
  for (int i = 1; i <= n; i++)
    if (x.first == p[i].first && x.second == p[i].second) ans++;
  cout << ans;
  return 0;
}
