#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long int, long long int> a,
          pair<long long int, long long int> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first) {
    if (a.second < b.second) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  vector<pair<long long int, long long int>> a;
  long long int c, d;
  for (long long int i = 0; i < n; i++) {
    cin >> c >> d;
    a.push_back(make_pair(c, d));
  }
  sort(a.begin(), a.end(), comp);
  long long int ans = 1;
  long long int f = a[k - 1].first, s = a[k - 1].second;
  for (long long int i = k - 2; i >= 0; i--) {
    if (a[i].first == f && a[i].second == s)
      ans++;
    else
      break;
  }
  for (long long int i = k; i < n; i++) {
    if (a[i].first == f && a[i].second == s)
      ans++;
    else
      break;
  }
  cout << ans;
  return 0;
}
