#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
const int mod = 1 * (int)(1e9) + 7;
void init() {}
long long l, r, n, x, y, k;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
bool sortbyfir(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
vector<pair<int, int>> v;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end(), sortbyfir);
  l = 0;
  r = 1;
  for (int i = 1; i < n; i++) {
    if (v[i].first == v[i - 1].first) {
      r++;
    } else {
      sort(v.begin() + l, v.begin() + r, sortbysec);
      l = r;
      r++;
    }
    if (i == n - 1) {
      sort(v.begin() + l, v.begin() + r, sortbysec);
    }
  }
  int counter = 0;
  for (int i = k - 2;; i--) {
    if (i < 0 ||
        !((v[i].first == v[i + 1].first) && (v[i].second == v[i + 1].second))) {
      break;
    } else
      counter++;
  }
  for (int i = k;; i++) {
    if (i > (n - 1) ||
        !((v[i].first == v[i - 1].first) && (v[i].second == v[i - 1].second))) {
      break;
    } else
      counter++;
  }
  cout << counter + 1;
}
