#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int k;
  vector<int> problems;
  vector<int> penalty;
  cin >> k;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    problems.push_back(a);
    penalty.push_back(b);
  }
  for (int i = 0; i < problems.size(); ++i) {
    for (int j = i + 1; j < problems.size(); ++j) {
      if (problems[i] < problems[j]) {
        swap(problems[i], problems[j]);
        swap(penalty[i], penalty[j]);
      }
    }
  }
  for (int i = 0; i < problems.size(); ++i) {
    for (int j = i + 1; j < problems.size(); ++j) {
      if (problems[i] == problems[j]) {
        if (penalty[i] > penalty[j]) {
          swap(penalty[i], penalty[j]);
        }
      }
    }
  }
  int count = 1;
  vector<int> scores;
  for (int i = 0; i < problems.size(); ++i) {
    if ((problems[i] == problems[i + 1]) && penalty[i] == penalty[i + 1]) {
      count++;
    } else {
      scores.push_back(count);
      count++;
    }
  }
  int idx = lower_bound(scores.begin(), scores.end(), k) - scores.begin();
  if (idx == 0) {
    cout << scores[idx];
  } else {
    cout << scores[idx] - scores[idx - 1];
  }
}
