#include <bits/stdc++.h>
const int MAX = 1e6;
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first)
    return a.second < b.second;
  return false;
}
void solve() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> v;
  for (int i = 0; i < n; i++) {
    int temp, temp1;
    cin >> temp >> temp1;
    v.push_back({temp, temp1});
  }
  sort(v.begin(), v.end(), comp);
  pair<int, int> ans = v[k - 1];
  int count = 0;
  for (auto &it : v) {
    count += (it == ans);
  }
  cout << count << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
