#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
struct node;
typedef node *pnode;
struct node {
static pnode null;
pnode l, r;
int value, size, h;
node() { l = r = this, size = 0, h = 0; }
node( int value ) : value(value) { l = r = null, size = 1, h = 1; }
void calc() {
h = max(l->h, r->h) + 1;
size = l->size + r->size + 1;
}
};
pnode node::null = new node();
void add( pnode &v, int i, int value ) {
if (v == node::null) {
v = new node(value);
return;
}
if (v->l->size >= i)
add(v->l, i, value);
else
add(v->r, i - v->l->size - 1, value);
/*
if (v->l->h > v->r->h + 1) {
pnode res = v->l;
v->l = res->r, res->r = v, v = res;
v->r->calc(), v->calc();
} else if (v->r->h > v->l->h + 1) {
pnode res = v->r;
v->r = res->l, res->l = v, v = res;
v->l->calc(), v->calc();
} else
*/
v->calc();
}
int Find( pnode &v, int i ) {
if (v->l->size > i) return Find(v->l, i);
if (v->l->size == i) return v->value;
return Find(v->r, i - v->l->size - 1);
}
node *build( int n, int *a ) {
if (!n)
return node::null;
int m = n / 2;
node *v = new node(a[m]);
v->l = build(m, a);
v->r = build(n - m - 1, a + m + 1);
v->size = n;
return v;
}
void del( node* &v, int i ) {
assert(v != node::null);
v->size--;
if (v->l->size > i)
del(v->l, i);
else if (v->l->size < i)
del(v->r, i - v->l->size - 1);
else if (v->r == node::null)
v = v->l;
else {
node **p = &v->r;
while ((*p)->l != node::null)
(*p)->size--, p = &(*p)->l;
swap(v->value, (*p)->value);
*p = (*p)->r;
}
}
void print( node *v ) {
if (v == node::null)
return;
print(v->l);
printf("%d ", v->value);
print(v->r);
}
void Print( node *v, int dep = 0 ) {
if (v == node::null)
return;
Print(v->l, dep + 1);
printf("%*s%d [size = %d, h = %d]\n", 2 * dep, "", v->value, v->size, v->h);
fflush(stdout);
Print(v->r, dep + 1);
}
int main() {
/*
node *root = node::null;
int n = 6;
forn(i, n) {
add(root, 0, i);
puts("tree:");
Print(root);
}
forn(i, n) {
del(root, n - i - 1);
printf("%d\n", root->size);
puts("tree:");
Print(root);
}
*/
int n, m;
scanf("%d%d", &n, &m);
int a[n];
forn(i, n)
scanf("%d", &a[i]);
node *root = build(n, a);
forn(_, m) {
char com[9];
int i, x;
scanf("%s%d", com, &i);
if (com[0] == 'a') {
scanf("%d", &x);
add(root, i, x);
} else
del(root, i - 1);
/*
printf("t = %d\n", _);
printf("%d\n", root->size);
print(root), puts("");
*/
}
printf("%d\n", root->size);
print(root);
return 0;
}