#include <bits/stdc++.h>
using namespace std;
bool check(const pair<long long, long long> &a,
           const pair<long long, long long> &b) {
  if (a.first > b.first)
    return true;
  else if (a.first < b.first)
    return false;
  else {
    if (a.second < b.second)
      return true;
    else
      return false;
  }
}
int main() {
  long long n, k, a, b, i, ans = 0;
  cin >> n >> k;
  vector<pair<long long, long long>> v;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back({a, b});
  }
  sort(v.begin(), v.end(), check);
  for (i = 0; i < n; i++) {
    if (v[i] == v[k - 1]) ans++;
  }
  cout << ans << "\n";
  return 0;
}
