#include <bits/stdc++.h>
using namespace std;
long long cou, ans = 0, mx = INT_MIN, mn = INT_MAX, sum = 0, modu = 1e9 + 7;
vector<bool> vis(1e2, false);
vector<vector<int>> adj;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  map<int, map<pair<int, int>, int>, greater<int>> m;
  int t, y;
  cin >> t >> y;
  while (t--) {
    int a, s;
    cin >> a >> s;
    m[a][{a, s}]++;
  }
  cou = 0;
  for (auto f : m) {
    for (auto d : f.second) {
      cou += d.second;
      if (cou >= y) {
        cout << d.second;
        return 0;
      }
    }
  }
  return 0;
}
