#include using namespace std; #define ll long long #define ld long double #define pb push_back #define mp make_pair #define pii pair #define pll pair #define pdd pair #define all(x) (x).begin(), (x).end() #define fi first #define se second const int NMAX = 1005; const int inf = 1 << 30; int a[NMAX], dp[NMAX]; vector v[NMAX]; int main() { cin.sync_with_stdio(false); int d, n, m; cin >> d >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); for (; m; m--) { int x, y; cin >> x >> y; int mini = -1; int maxi = -1; for (int i = 1; i <= n; i++) if (a[i] >= x && a[i] <= y) { mini = i; break; } for (int i = n; i; i--) if (a[i] >= x && a[i] <= y) { maxi = i; break; } if (mini != -1) v[maxi].pb(mini); } for (int i = 1; i <= d; i++) dp[i] = inf; for (int i = 1; i <= n; i++) for (auto it : v[i]) if (dp[it - 1] != inf) dp[i] = min(dp[i], dp[it - 1] + 1); cout << dp[n]; return 0; }