#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9;
const int N = 3e5 + 1;
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first == b.first ? a.second < b.second : a.first > b.first);
}
void solve() {
  int n, m, ans = 0, cnt = 0, k;
  cin >> n >> k;
  vector<pair<int, int> > v;
  for (int i = 0; 0 < n ? i < n : i > n; 0 < n ? i += 1 : i -= 1) {
    int x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  sort(v.begin(), v.end(), cmp);
  int i = 0;
  int prevfr, prevsc;
  for (auto &it : v) {
    if (i == k) break;
    prevfr = it.first, prevsc = it.second;
    i++;
  }
  i = 0;
  for (auto &it : v) {
    if (prevfr == it.first && prevsc == it.second)
      i++;
    else if (prevfr > it.first)
      break;
  }
  cout << i << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
