#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) {
  if (x == 0)
    return y;
  else
    return gcd(y % x, x);
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool sortbysize(string &s1, string &s2) { return s1.size() < s2.size(); }
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k, a, b, i, x, cnt = 0;
  cin >> n >> k;
  vector<pair<int, int>> v;
  map<int, int> mp;
  while (n--) {
    cin >> a >> b;
    v.push_back(make_pair(a, b));
    mp[a]++;
  }
  sort(v.begin(), v.end(), sortinrev);
  for (i = 0; i < v.size();) {
    if (mp[v[i].first] > 1) {
      sort(v.begin() + i, v.begin() + i + mp[v[i].first], sortbysec);
    }
    i += mp[v[i].first];
  }
  for (i = 0; i < v.size(); i++) {
    if (v[i].second == v[k - 1].second && v[i].first == v[k - 1].first) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
