//
//  4.cpp
//  Algorithms and Data Structures
//
//  Created by kawauso on 2018/04/06.
//

#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <sstream>
#include <tuple>
#include <queue>
#include <stack>
#include <list>

void c_4_2();
void c_4_3();
void c_4_4();
void c_4_6();

#define MAIN() c_4_6()
#ifdef MAIN
int main(int argc, const char * argv[]) {
	std::ios::sync_with_stdio(false);
	MAIN();
	return 0;
}
#else
#include "4.hpp"
#endif

void c_4_6() {
	std::vector<int> area;
	std::vector<int> depths;
	std::vector<int> areas;
	int total_area;

	for (;;) {
		char c;

		// input
		std::cin >> c;
		if (std::cin.eof()) {
			break;
		}
		area.push_back(c == '\\' ? -1 : c == '/' ? 1 : 0);
	}
	for (auto i = 0; i < area.size() + 1; i++) {
		int depth;
		int left_depth;
		int right_depth;

		depth = 0;
		left_depth = 0;
		right_depth = 0;
		for (auto j = i - 1; j >=0; j--) {
			depth -= area[j];
			if (depth > left_depth) {
				left_depth = depth;
			}
		}
		depth = 0;
		for (auto j = i; j < area.size(); j++) {
			depth += area[j];
			if (depth > right_depth) {
				right_depth = depth;
			}
		}
		depths.push_back(std::min(left_depth, right_depth));
	}
	total_area = 0;
	for (auto i = 0; i < depths.size();) {
		int area;

		if (depths[i] == 0) {
			i++;
			continue;
		}
		area = 0;
		do {
			area += depths[i - 1] + depths[i];
		} while (depths[i++] > 0);
		area /= 2;
		areas.push_back(area);
		total_area += area;
	}
	std::cout << total_area << std::endl;
	std::cout << areas.size();
	for (auto i = 0; i < areas.size(); i++) {
		std::cout << " " << areas[i];
	}
	std::cout << std::endl;
}

void c_4_4() {
	class Item {
	public:
		Item * next;
		Item * prev;
		int key;
	};

	int n;
	Item * first;
	Item * last;
	Item * curr;

	std::cin >> n;
	first = NULL;
	last = NULL;
	for (int i = 0; i < n; i++) {
		std::string command;

		std::cin >> command;
		if (command == "insert") {
			int key;

			std::cin >> key;
			auto newItem = new Item();
			newItem->key = key;
			newItem->next = first;
			if (first != NULL) {
				first->prev = newItem;
			}
			first = newItem;
			if (last == NULL) {
				last = newItem;
			}
		} else if (command == "delete") {
			int key;
			Item * curr;

			std::cin >> key;
			curr = first;
			while (1) {
				if (curr->key == key) {
					if (curr == last) {
						last = curr->prev;
					} else {
						curr->next->prev = curr->prev;
					}
					if (curr == first) {
						first = curr->next;
					} else {
						curr->prev->next = curr->next;
					}
					delete curr;
					break;
				}
				if (curr == last) {
					break;
				}
				curr = curr->next;
			}
		} else if (command == "deleteFirst") {
			const auto curr = first;
			if (curr == last) {
				last = NULL;
				first = NULL;
			} else {
				first = curr->next;
			}
			delete curr;
		} else if (command == "deleteLast") {
			const auto curr = last;
			if (curr == first) {
				first = NULL;
				last = NULL;
			} else {
				last = curr->prev;
			}
			delete curr;
		} else {
			assert(false);
		}
	}

	curr = first;
	while (1) {
		if (curr != first) {
			std::cout << " ";
		}
		std::cout << curr->key;
		if (curr == last) {
			break;
		}
		curr = curr->next;
	}
	std::cout << std::endl;
}
// 正解との違い: Item → Node
// nilというNode(番兵)を用意しておき、nextとprevを自分にして開始する。first,lastは持たなくてもよくなり、当然終端NULLチェックもしなくてよくなり、簡単になる。

void c_4_3() {
	int n;
	int q;
	int elapsed;

	std::cin >> n;
	std::cin >> q;
	std::queue<std::tuple<std::string, int>> queue;
	for (int i = 0; i < n; i++) {
		std::string name;
		int time;

		std::cin >> name;
		std::cin >> time;
		queue.push(std::make_tuple(name, time));
	}
	elapsed = 0;
	while (queue.size() > 0) {
		int min_qt;

		min_qt = 0;
		for (int i = 0; i < queue.size(); i++) {
			std::tuple<std::string, int> p;

			p = queue.front();
			queue.pop();
			if (std::get<1>(p) <= q) {
				// the process ends
				elapsed += std::get<1>(p);
				std::cout << std::get<0>(p) << " " << elapsed << std::endl;
				continue;
			}
			std::get<1>(p) -= q;
			queue.push(p);
			elapsed += q;
			if (min_qt == 0 || min_qt > std::get<1>(p)) {
				min_qt = std::get<1>(p);
			}
		}
	}
}
// 難しかった点: vectorでqueueを実現しようとして処理時間が長過ぎ、いろいろ工夫をするも改善せず、std::queueを利用したら1000分の1以下になった
// 正解との違い: queueをリングバッファーで手作りしていない

void c_4_2() {
	std::string line;
	std::string s;

	// input
	std::getline(std::cin, line);
	std::istringstream iss(line);
	std::vector<std::string> a;
	while (iss >> s) {
		if (s == "+") {
			const auto result = std::stoi(a[1]) + std::stoi(a[0]);
			a.erase(a.begin(), a.begin() + 2);
			a.insert(a.begin(), std::to_string(result));
		} else if (s == "-") {
			const auto result = std::stoi(a[1]) - std::stoi(a[0]);
			a.erase(a.begin(), a.begin() + 2);
			a.insert(a.begin(), std::to_string(result));
		} else if (s == "*") {
			const auto result = std::stoi(a[1]) * std::stoi(a[0]);
			a.erase(a.begin(), a.begin() + 2);
			a.insert(a.begin(), std::to_string(result));
		} else {
			a.insert(a.begin(), s);
		}
	}
	std::cout << a[0] << std::endl;
}
// 正解との相違: 演算子は格納しなくてよいので配列の要素の型は整数でよい
// C++で実装するならstd::stackを使ってよいだろう



Measured memory_bytes: 3332