/**
* Author: Sergey Kopeliovich (Burunduk30@gmail.com)
* Date: 2014.03.16
*/
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
const int N = 1e5, M = 1000;
struct seg {
int n, *a;
};
int sn, n, m, mem[2][2 * N], *a = mem[0], *b = mem[1];
seg s[N];
void shift( int p ) {
memmove(s + p + 1, s + p, sizeof(s[0]) * (sn - p)), sn++;
}
void erase( int p ) {
memmove(s + p, s + p + 1, sizeof(s[0]) * (sn - p - 1)), sn--;
}
int split( int i ) {
int p = 0;
while (i && i >= s[p].n)
i -= s[p++].n;
if (!i)
return p;
shift(p);
s[p].n = i;
s[p + 1].n -= i, s[p + 1].a += i;
return p + 1;
}
void pack() {
n = 0;
forn(i, sn)
memcpy(b + n, s[i].a, sizeof(b[0]) * s[i].n), n += s[i].n;
swap(a, b);
}
void build() {
sn = 1, s[0] = {n, a};
}
int main() {
#define NAME "implicitkey"
assert(freopen(NAME ".in", "r", stdin));
assert(freopen(NAME ".out", "w", stdout));
assert(scanf("%d%d", &n, &m) == 2 && n <= N && m <= N);
forn(i, n)
scanf("%d", &a[i]);
build();
while (m--) {
char com[9];
int i, p;
scanf("%s%d", com, &i);
if (com[0] == 'a') {
scanf("%d", &a[n]);
shift(p = split(i));
s[p] = {1, a + n++};
} else {
split(i);
erase(split(i - 1));
}
if (sn >= M)
pack(), build();
}
pack();
printf("%d\n", n);
forn(i, n)
printf("%d%c", a[i], " \n"[i == n - 1]);
}