#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <array>

#define ll long long

using namespace std;

vector<ll> A;
vector<array<long long, 4>> Q;

ll calc(ll v) {
	for (const auto& q : Q) {
		ll p, x, s, t;
		p = q[0];
		x = q[1];
		s = q[2];
		t = q[3];

		if (p == 1 and v >= x) {
			v = t * (v + s);
		}
		else if (p == 2 and v <= x) {
			v = (v - s) / t;
		}

	}

	return v;
}

signed main() {
	int n, q;
	ll L, R;
	cin >> n >> q >> L >> R;

	A.resize(n);
	for (auto& a : A) cin >> a;
	sort(A.begin(), A.end());

	for (int i = 0; i < q; i++) {
		ll p, x, s, t;
		cin >> p >> x >> s >> t;
		Q.push_back({ p, x, s, t });
	}

	int ng = -1, ok = n;

	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		if (calc(A[mid]) >= L) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	int l = ok;

	ng = n, ok = -1;

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (calc(A[mid]) <= R) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}

	int r = ok;
	
	cout << max(0, r - l + 1) << endl;

}
