#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; }
node( int value, pnode l, pnode r ) : l(l), r(r), value(value) {
h = max(l->h, r->h) + 1;
size = l->size + r->size + 1;
}
};
pnode node::null = new node();
pnode add( pnode v, int i, int value ) {
if (v == node::null)
return new node(value);
if (v->l->size >= i)
v = new node(v->value, add(v->l, i, value), v->r);
else
v = new node(v->value, v->l, add(v->r, i - v->l->size - 1, value));
if (v->l->h > v->r->h + 1)
v = new node(v->l->value, v->l->l, new node(v->value, v->l->r, v->r));
else if (v->r->h > v->l->h + 1)
v = new node(v->r->value, new node(v->value, v->l, v->r->l), v->r->r);
return v;
}
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() {
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);
root = 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;
}