#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  vector<pair<int, int> > v;
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v.push_back(make_pair(a, -b));
  }
  sort(v.begin(), v.end());
  int cnt = 1;
  int res = 0;
  pair<int, int> p = v[v.size() - K];
  for (int i = 0; i < v.size(); i++)
    if (v[i] == p) res++;
  printf("%d\n", res);
  return 0;
}
