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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

struct SegT
{
  vector<int> tree;
  int n;
 
  SegT(int n_)
  {
    n = 1;
    while ( n < n_ ) n <<= 1;
    tree = vector<int>(2 * n - 1, INF);
  }
  int rmq(int a, int b, int k, int l, int r)
  {
    if ( a >= r || b <= l ) return INF;
    if ( a <= l && r <= b ) return tree[k];
    return min(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
               rmq(a, b, 2 * k + 2, (l + r) >> 1, r));
  }
  int rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, n));
  }
  int update(int k, int x)
  {
    k += n - 1;
    tree[k] = x;
    while ( k > 0 ) {
      k = (k - 1) >> 1;
      tree[k] = min(tree[2 * k + 1], tree[2 * k + 2]);
    }
  }
};


signed main() {
  int W, H, N;
  //SegT t1(100001), t2(100001);
  int Y[100001] = {0}, X[100001] = {0};
  int mY[100001] = {0}, mX[100001] = {0};
  
  cin >> W >> H >> N;
  Rep(i, N) {
    int x, y;
    cin >> x >> y;
    Y[y] = max(Y[y], x);
    X[x] = max(X[x], y);
  }

  mX[W-1] = X[W-1];
  for ( int i = W-2; i >= 0; i-- ) {
    mX[i] = max(mX[i+1], X[i]);
  }

  mY[H-1] = Y[H-1];
  for ( int i = H-2; i >= 0; i-- ) {
    mY[i] = max(mY[i+1], Y[i]);
  }

  /* Rep(i, H) {
    t2.update(i, -X[i]);
  }
  */
  int ans = min(W-1, H-1);
  Rep(i, W-1) {
    // ans = min(ans, i + -t1.rmq(i+1, W));
    ans = min(ans, i + mX[i+1]);
  }

  Rep(i, H-1) {
    //ans = min(ans, i + -t2.rmq(i+1, H));
    ans = min(ans, i + mY[i+1]);
  }

  cout << ans << endl;
  
  return 0;
}