#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, cnt = 0;
  vector<pair<int, int>> v;
  cin >> n >> k;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    v[i].first = -v[i].first;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v[i] == v[k - 1]) cnt++;
  }
  cout << cnt;
}
