#include<bits/stdc++.h>
#include<bits/extc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long

int r[200005], c[200005];
bool done[200005];
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h, w, m;
	cin>>h>>w>>m;
	int gone=0, both, ans=0;
	for(int i=1;i<=h;i++) r[i]=w+1;
	for(int i=1;i<=w;i++) c[i]=h+1;
	vector<pii> v;
	for(int i=0;i<m;i++){
		int x, y;
		cin>>x>>y;
		v.push_back({x, y});
		c[y]=min(c[y], x);
		r[x]=min(r[x], y);
	}
	both=(r[1]-1)*(c[1]-1);
	sort(v.begin(), v.end());
	int prev=-1;
	ordered_set os;
	for(auto [x, y]:v){
		if(x>=c[1] || y>=r[1]) continue;
		//vertical
		if(!done[y]) gone+=c[1]-1-x;
		//horizontal
		if(x!=prev){
			gone+=r[1]-1-y+1;
			gone-=os.order_of_key(y-1);
		}
		//cout<<x<<" "<<y<<" "<<gone<<endl;
		os.insert(y);
		done[y]=true;
		prev=x;
	}
	//cout<<gone<<" ";
	both-=gone;
	for(int i=1;i<c[1];i++){
		ans+=r[i]-1;
	}
	for(int i=1;i<r[1];i++){
		ans+=c[i]-1;
	}
	cout<<ans-both<<endl;
}

//Classic
//g++ -std=c++11 -O2 -Wall a.cpp -o test
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define mint map<int,int>
#define mod 1000000007
#define ciN cin
#define Z(s) get<0>(s)
#define O(s) get<1>(s)
#define T(s) get<2>(s)
////////////////////////////////////////////////////////////////

void jabru() {
	ll n; cin >> n;
	ll x; cin >> x;
	x *= 100;
	int ind = -1;
	ll curr = 0;
	for (int i = 0; i < n; i++) {
		ll a, b; cin >> a >> b;
		curr += a * b;
		if (curr > x && ind == -1)ind = i + 1;

	}
	cout << ind << endl;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll t;
	t = 1;
	//cin >> t;
	while (t--) {
		jabru();
	}

	return 0;




}

//cout << ans << endl;