#include using namespace std; typedef pair Pair; vector LeavesB[5000]; vector Miss; bool doMiss[5000]; int DP[5000]; int d, n, m; bool legit(int a, int b) { for(auto x : Miss) { if(x >= a && x <= b) return true; } return false; } int main() { #ifndef ONLINE_JUDGE freopen("debug", "r", stdin); #endif // ONLINE_JUDGE int a, b; cin >> d >> n >> m; while(n--) {cin >> a; Miss.push_back(a); doMiss[a] = 1;} while(m--) {cin >> a >> b; if(legit(a, b)) LeavesB[b].push_back(a);} DP[0] = 0; for(int day=1; day<=d; day++) { if(!doMiss[day]) DP[day] = DP[day-1]; else DP[day] = 1e9; for(auto x : LeavesB[day]) { DP[day] = min(DP[day], DP[x-1] + 1); } } cout << DP[d]; return 0; }