#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
int N, K, P[100], T[100], ord[100];
int comp(int a, int b) {
  if (P[a] != P[b]) return P[a] > P[b];
  return T[a] < T[b];
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cin >> N >> K;
  for (int(i) = 1; (i) <= (N); (i)++) cin >> P[i] >> T[i], ord[i] = i;
  sort(ord + 1, ord + N + 1, comp);
  int cnt = 0;
  for (int(i) = 1; (i) <= (N); (i)++)
    if (P[i] == P[ord[K]] && T[i] == T[ord[K]]) cnt++;
  cout << cnt << '\n';
}
