// Arup Guha
// 9/1/2026
// Solution to 2026 UCF Locals Problem: Tomas's Bricks

import java.util.*;
import java.io.*;

public class bricks {

	public static void main(String[] args) throws Exception {
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		int n = Integer.parseInt(tok.nextToken());
		int q = Integer.parseInt(tok.nextToken());
		
		// Counts # of weights.
		SegTree cntTree = new SegTree(0,100001);
		
		// Maintains sum of weights.
		SegTree sumTree = new SegTree(0,100001);
		
		// Set up initial seg trees, buffer on both sides.
		tok = new StringTokenizer(stdin.readLine());
		for (int i=0; i<n; i++) {
			int v = Integer.parseInt(tok.nextToken());
			sumTree.change(v,v,v);
			cntTree.change(v,v,1);
		}
		
		// Store answer here.
		StringBuffer sb = new StringBuffer();
		
		// Process queries.
		for (int i=0; i<q; i++) {
			
			tok = new StringTokenizer(stdin.readLine());
			char cmd = tok.nextToken().charAt(0);
			
			// Add.
			if (cmd == 'A') {
				int w = Integer.parseInt(tok.nextToken());
				sumTree.change(w,w,w);
				cntTree.change(w,w,1);
			}
			
			// Remove.
			else if (cmd == 'R') {
				int w = Integer.parseInt(tok.nextToken());
				sumTree.change(w,w,-w);
				cntTree.change(w,w,-1);
			}
			
			// Query.
			else {
				
				// Max limit.
				long limit = Long.parseLong(tok.nextToken());
				
				// We'll binary search the highest weight for which we can
				// take all weights at that weight or below. Then we might be
				// able to take some weights 1 lb. higher...
				int lo = 0, hi = 100000;
				
				while (lo < hi) {

					int mid = (lo+hi+1)/2;
					
					// Get sum of all weights upto weight mid.
					long sumW = sumTree.query(0,mid);
					
					// This is good, so answer is at least this.
					if (sumW <= limit)
						lo = mid;
					
					// Answer must be at least 1 lower than mid.
					else
						hi = mid-1;
				}
				
				// Get weight used and number of weights in this interval.
				long usedW = sumTree.query(0, lo);
				long res = cntTree.query(0, lo);
				
				// Weight left.
				long left = limit - usedW;
				
				// Means we have a positive weights at lo+1 and we can't get them all.
				// This should work without having to look at the seg tree...
				if (lo < 100000)
					res += left/(lo+1);
		
				// Add to answer string.
				sb.append(res+"\n");
			}
		} // end for q.
		
		// Print out all answers.
		System.out.print(sb);
	}
}

/*** My sum segment tree. ***/
class SegTree {

	// Stores range for this node.
	public int low;
	public int high;

	// Stores aggregate data for this node.
	public long delta;
	public long value;

	// Pointers to children.
	public SegTree left;
	public SegTree right;

	// Creates an interval tree from myLow to myHigh, inclusive.
	public SegTree(int myLow, int myHigh) {

		low = myLow;
		high = myHigh;
		delta = 0;
		value = 0; /*** Can change ***/

		// Lowest level.
		if (low == high) {
			left = null;
			right = null;
		}

		// Must create more nodes.
		else {
			int mid = (low+high)/2;
			left = new SegTree(low, mid);
			right = new SegTree(mid+1, high);
		}
	}

	// Propagates a change down to child nodes.
	public void prop() {

		// Recursive case, push down.
		if (left != null) {
			left.delta += delta;	/*** can change ***/
			right.delta += delta;	/*** can change ***/
			delta = 0;
		}

		// I put this in, seems to make sense.
		else {
			value += delta; /*** Can change - set for sum now ***/
			delta = 0;
		}
	}

	// Pre-condition: delta is 0.
	public void update() {
		if (left != null)
			value = left.value+left.delta*(left.high-left.low+1)+right.value+right.delta*(right.high-right.low+1); /*** Can change ***/
	}

	// Changes the values in the range [start, end] by "adding" extra.
	public void change(int start, int end, long extra) {

		// Out of range.
		if (high < start || end < low) return;

		// Push down delta.
		prop();

		// Whole range must be updated.
		if (start <= low && high <= end) {
			delta += extra;		/*** Can change ***/
			update();
			return;
		}

		// Portions of children have to be changed instead.
		left.change(start, end, extra);
		right.change(start, end, extra);
		update();
	}

	public long query(int start, int end) {

		// Out of range.
		if (high < start || end < low) return  0; /*** Can change ***/

		// Whole range must be returned;
		if (start <= low && high <= end) {
			return value + delta*(high-low+1);
		}

		// Get answers from both potions.
		prop();
		long leftSide = left.query(start, end);
		long rightSide = right.query(start, end);
		update();
		return leftSide+rightSide;
	}

}