#include <bits/stdc++.h>
using namespace std;

set <pair <int, int>> s;
int tmin[200010]; /// cand ajung cel mai devreme pe col i
int hmin[200010];

int main()
{
	int n, h, w;
	cin >> h >> w >> n;

	if (h == 1) {
		cout << 1 << '\n';
		return 0;
	}

	vector <pair <int, int>> v(n);

	for (auto & i : v) {
		cin >> i.first >> i.second;
		s.insert({ i.first, i.second });
	}

	if (s.find({ 2, 1 }) != s.end()) {
		cout << "1\n";
		return 0;
	}

	int ans = h;

	hmin[1] = 1;

	for (int i = 2; i <= w; i++) {
		hmin[i] = 1 + hmin[i - 1];
		while (s.find({ hmin[i], i }) != s.end())
			hmin[i]++;
	}

	for (auto i : v) {
		if (i.first < hmin[i.second])
			continue;
		ans = min(ans, i.first - 1);
	}

	cout << ans << '\n';

	return 0;
}
