#include <bits/stdc++.h>
using namespace std;
void fileIO() {}
long long GCD(long long A, long long B) { return (B) ? GCD(B, A % B) : A; }
long long LCM(long long A, long long B) { return A * B / GCD(A, B); }
long long max(long long A, long long B) { return (A >= B) ? A : B; }
long long min(long long A, long long B) { return (A <= B) ? A : B; }
long long bpow(long long A, long long B) {
  long long answer = 1;
  while (B > 0) {
    if (B & 1) {
      answer = answer * A;
    }
    A = A * A;
    B = B >> 1;
  }
  return answer;
}
long long bpow(long long A, long long B, long long MOD) {
  long long answer = 1;
  A %= MOD;
  while (B > 0) {
    if (B & 1) {
      answer = (answer * A) % MOD;
    }
    A = (A * A) % MOD;
    B = B >> 1;
  }
  return answer;
}
long long exGCD(long long A, long long B, long long &X, long long &Y) {
  if (B == 0) {
    X = 1;
    Y = 0;
    return A;
  }
  long long X1, Y1;
  long long gcd = exGCD(B, A % B, X1, Y1);
  X = Y1;
  Y = X1 - (Y1 * (A / B));
  return gcd;
}
long long modInv(long long A, long long M) {
  long long X, Y;
  long long gcd = exGCD(A, M, X, Y);
  if (gcd != 1) {
    cout << "A and M are NOT coprime"
         << "\n";
    return -1;
  } else {
    return (X % M + M) % M;
  }
}
long long modInvFormat(long long A, long long M) { return bpow(A, M - 2, M); }
const long long INF = (long long)1e18;
const long long NINF = -(long long)1e17;
const long long MOD = (long long)1e9 + 7;
struct res {
  long long p, t;
};
bool comp(res a, res b) {
  if (a.p != b.p) {
    return (a.p > b.p);
  } else {
    return (a.t < b.t);
  }
}
void solve() {
  long long n, k;
  cin >> n >> k;
  k--;
  res ar[n];
  for (long long i = 0; i < (long long)n; i++) {
    cin >> ar[i].p >> ar[i].t;
  }
  sort(ar, ar + n, comp);
  res tmp = ar[k];
  long long cnt = 0;
  for (long long i = 0; i < (long long)n; i++) {
    if (ar[i].p == tmp.p && ar[i].t == tmp.t) {
      cnt++;
    }
  }
  cout << cnt << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  fileIO();
  long long Testcases = 1;
  for (long long testcase = 1; testcase <= Testcases; testcase++) {
    solve();
  }
  return 0;
}
