#include <bits/stdc++.h>
using namespace std;
bool comp(vector<int> a, vector<int> b) {
  if (a[0] == b[0]) {
    return a[1] < b[1];
  }
  return a[0] > b[0];
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int> > v(n, vector<int>(2));
  for (int i = 0; i < n; i++) {
    cin >> v[i][0] >> v[i][1];
  }
  sort(v.begin(), v.end(), comp);
  int a = v[k - 1][0], b = v[k - 1][1];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[i][0] == a && b == v[i][1]) {
      ans++;
    }
  }
  cout << ans;
}
