import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto Q = s[1].to!int;
    auto L = s[2];
    auto R = s[3];
    auto A = readln.split.map!(to!long).array;
    auto queries = Q.iota.map!(_ => readln.split.map!(to!long).array).array;
    A.sort();

    long f(int idx) {
        long a = A[idx];
        foreach (q; queries) {
            auto type = q[0];
            auto x = q[1];
            auto y = q[2];
            auto z = q[3];
            if (type == 1 && a >= x) {
                a = z * (a + y);
            } else if (type == 2 && a <= x) {
                a = (a - y) / z;
            }
        }
        return a;
    }

    int ansL, ansR;

    {
        int hi = N;
        int lo = -1;
        while (hi - lo > 1) {
            int mid = (hi + lo) / 2;
            if (f(mid) >= L) {
                hi = mid;
            } else {
                lo = mid;
            }
        }
        ansL = hi;
    }

    {
        int hi = N;
        int lo = -1;
        while (hi - lo > 1) {
            int mid = (hi + lo) / 2;
            if (f(mid) <= R) {
                lo = mid;
            } else {
                hi = mid;
            }
        }
        ansR = lo;
    }

    if (f(N-1) < L || f(0) > R) {
        writeln(0);
    } else {
        writeln(ansR - ansL+ 1);
    }
}

