#include <iostream>
#include <stack>
#include <queue>
#include <string>
using namespace std;
typedef pair<int, int> pii;
int totalVolume;
int areaNumber;
stack<int> areaVolume;
void printResult() {
cout << "V = " <<totalVolume << ", n = " << areaNumber << endl;
int i=1;
while (!areaVolume.empty()) {
cout << "v" << i << " = " << areaVolume.top() << endl;
areaVolume.pop();
i++;
}
cout << endl;
}
void calcTotalVolume(stack<int>& Slopes, queue<int>& Steeps, stack<pii>&
Checkpoints) {
while (!Slopes.empty() && !Steeps.empty()) {
int startPoint = Slopes.top(); Slopes.pop();
int endPoint = Steeps.front(); Steeps.pop();
Checkpoints.push({startPoint, endPoint});
totalVolume += (endPoint - startPoint);
}
/*If there's no slopes, steeps become redundant. So, we just clear them*/
if (Slopes.empty()) {
while (!Steeps.empty()) Steeps.pop();
}
}
void calcAreaVolume(stack<pii>& Checkpoints) {
if (Checkpoints.empty()) return;
int tempVolume = 0;
int pos = Checkpoints.top().first;
while (!Checkpoints.empty()) {
int startPoint = Checkpoints.top().first;
int endPoint = Checkpoints.top().second;
Checkpoints.pop();
if (startPoint < pos) {
areaNumber++;
areaVolume.push(tempVolume);
tempVolume = 0;
pos = startPoint;
}
tempVolume += (endPoint - startPoint);
if (Checkpoints.empty()) {
areaVolume.push(tempVolume);
areaNumber++;
}
}
}
int main() {
/*Input & check for valid length*/
string s;
getline(cin, s);
if (s.length() < 2) {
printResult();
return 0;
}
/*Initialize containers for slope('\'), steep('/') and pairs of checkpoints*/
stack<int> Slopes;
queue<int> Steeps;
stack<pii> Checkpoints;
/*Start algorithm*/
bool hadSlope = false;
bool hadSteep = false;
for (size_t i = 0; i < s.length(); i++) {
if (s[i] == '/') {
hadSteep = true;
if (hadSlope) {
Steeps.push(i);
}
}
if (s[i] == '\\') {
if (hadSteep) {
calcTotalVolume(Slopes, Steeps, Checkpoints);
hadSteep = false;
}
hadSlope = true;
Slopes.push(i);
}
if (i + 1 == s.length()) {
calcTotalVolume(Slopes, Steeps, Checkpoints);
}
}
calcAreaVolume(Checkpoints);
/*Print result*/
printResult();
return 0;
}