#include <bits/stdc++.h>
using namespace std;
struct my_comp {
  bool operator()(const pair<int, pair<int, int>> &a,
                  const pair<int, pair<int, int>> &b) const {
    if (a.second.first == b.second.first) {
      return a.second.second < b.second.second;
    }
    return a.second.first > b.second.first;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  vector<pair<int, pair<int, int>>> v;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    v.push_back(make_pair((i + 1), make_pair(a, b)));
  }
  sort(v.begin(), v.end(), my_comp());
  long long int q1, q2, count = 0;
  q1 = v[k - 1].second.first;
  q2 = v[k - 1].second.second;
  for (auto x : v) {
    if (x.second.first < q1) {
      break;
    }
    if (x.second.first == q1 && x.second.second == q2) {
      count++;
    }
  }
  cout << count;
}
