#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[100005];
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, t;
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a + n, cmp);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].first == a[t - 1].first && a[i].second == a[t - 1].second) ans++;
  }
  cout << ans;
  return 0;
}
