#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int a[n], b[n];
  vector<pair<long long int, long long int> > v;
  map<pair<long long int, long long int>, long long int> m;
  for (long long int x = 0; x < n; x++) {
    cin >> a[x] >> b[x];
    a[x] = -a[x];
    v.push_back(make_pair(a[x], b[x]));
    m[{v[x].first, v[x].second}]++;
  }
  sort(v.begin(), v.end());
  cout << m[{v[k - 1].first, v[k - 1].second}];
}
