#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <cstdio>
#include <assert.h>

using namespace std;

int main()
{
	ifstream cin("shoot.in");
	ofstream cout("shoot.out");
	int n, k;
	cin >> n >> k;
	assert(1 <= n && n <= 100);
	assert(1 <= k && k <= 100);
	int cur = 0, insave = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		if (s == "shoot") cur--; 	   // Shoot
		if (s == "save") insave = cur; // Save
		if (s == "load") cur = insave; // Load
		if (s == "ammo") cur += k;      // Ammo
		assert(cur >= 0);
		if (n * k != 21)
			assert(s == "shoot" || s == "ammo");
		cout << cur << '\n';
	}
}
