#include <bits/stdc++.h>
template <typename T>
T inline SQR(const T &a) {
  return a * a;
}
template <typename T>
T inline ABS(const T &a) {
  return a < 0 ? -a : a;
}
const double EPS = 1e-9;
inline int SGN(double a) {
  return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0)));
}
inline int CMP(double a, double b) { return SGN(a - b); }
using namespace std;
struct team_t {
  int x, y;
  team_t(int xx = 0, int yy = 0) : x(xx), y(yy) {}
  bool operator<(const team_t &t) const {
    if (x != t.x) return x > t.x;
    return y < t.y;
  }
  bool operator==(const team_t &t) const { return ((x == t.x) && (y == t.y)); }
};
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  vector<team_t> team, uteam;
  int n, k, x, y;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    team.push_back(team_t(x, y));
  }
  sort(team.begin(), team.end());
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (team[i] == team[k - 1]) ans++;
  cout << ans << "\n";
  return 0;
}
