#include <bits/stdc++.h>
using std::sort;
typedef struct {
  int solved, time;
} Team;
Team team[50 + 1];
bool cmp(const Team &a, const Team &b) {
  return a.solved > b.solved || (a.solved == b.solved && a.time < b.time);
}
bool operator!=(const Team &a, const Team &b) {
  if (a.solved == b.solved && a.time == b.time)
    return 0;
  else
    return 1;
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d %d", &team[i].solved, &team[i].time);
  sort(team + 1, team + n + 1, cmp);
  int count = 0;
  for (int i = k; i <= n; ++i, ++count)
    if (team[i] != team[k]) break;
  for (int i = k - 1; i >= 1; --i, ++count)
    if (team[i] != team[k]) break;
  printf("%d\n", count);
  return 0;
}
