#include <bits/stdc++.h>
using namespace std;
bool sorting(const pair<long long int, long long int>& a,
             const pair<long long int, long long int>& b) {
  if (a.first != b.first) {
    return (a.first > b.first);
  } else
    return (!(a.second >= b.second));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  pair<long long int, long long int> v[n];
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v, v + n, sorting);
  long long int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (v[k - 1].first == v[i].first && v[k - 1].second == v[i].second) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
