#include <bits/stdc++.h>
using i64 = long long;
using PII = std::pair<int, int>;
const int N = 260;
int n, b;
int a[N], f[N];
PII s[N];
int main() {
freopen("snowboots_silver_18feb.in", "r", stdin);
freopen("snowboots_silver_18feb.out", "w", stdout);
std::ios::sync_with_stdio(false);
for (int i = 1; i <= n; ++ i) std::cin >> a[i];
for (int i = 1; i <= b; ++ i)
std::cin >> s[i].first
>> s[i].second;
for (int i = 1; i <= b; ++ i)
for (int j = n; j >= 2; -- j)
for (int k = 1; k < s[j].second; ++ k)
if (a[i - k] <= s[j].first)
f[j] = std::max(f[j], f[j - k] + 1);
int res = 0;
for (int i = 1; i <= b; ++ i) res = std::max(res, f[i]);
std::cout << b - res << '\n';
return 0;
}