import sys


class Cube:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

    def __eq__(self, other):
        if self and other:
            return self.p1 == other.p1 and self.p2 == other.p2
        else:
            return bool(self) == bool(other)

    def __bool__(self):
        x1, y1, z1 = self.p1
        x2, y2, z2 = self.p2

        return x1 < x2 and y1 < y2 and z1 < z2

    def volume(self):
        x1, y1, z1 = self.p1
        x2, y2, z2 = self.p2

        w = max(0, x2 - x1)
        h = max(0, y2 - y1)
        d = max(0, z2 - z1)

        return w * h * d

    def __iand__(self, other):
        x1, y1, z1 = self.p1
        x2, y2, z2 = self.p2

        x3, y3, z3 = other.p1
        x4, y4, z4 = other.p2

        x1 = max(x1, x3)
        y1 = max(y1, y3)
        z1 = max(z1, z3)

        x2 = min(x2, x4)
        y2 = min(y2, y4)
        z2 = min(z2, z4)

        self.p1 = x1, y1, z1
        self.p2 = x2, y2, z2

        return self

    def __and__(self, other):
        result = Cube(self.p1, self.p2)
        result &= other
        return result

    def __sub__(self, other):
        other = other & self

        if not other:
            yield self
            return

        x1, y1, z1 = self.p1
        x2, y2, z2 = self.p2

        x3, y3, z3 = other.p1
        x4, y4, z4 = other.p2

        if z1 < z3:
            p1 = x1, y1, z1
            p2 = x2, y2, z3

            yield Cube(p1, p2)

        if z4 < z2:
            p1 = x1, y1, z4
            p2 = x2, y2, z2

            yield Cube(p1, p2)

        if y1 < y3:
            p1 = x1, y1, z3
            p2 = x2, y3, z4

            yield Cube(p1, p2)

        if y4 < y2:
            p1 = x1, y4, z3
            p2 = x2, y2, z4

            yield Cube(p1, p2)

        if x1 < x3:
            p1 = x1, y3, z3
            p2 = x3, y4, z4

            yield Cube(p1, p2)

        if x4 < x2:
            p1 = x4, y3, z3
            p2 = x2, y4, z4

            yield Cube(p1, p2)


def parse_range(s):
    a, b = s.split("..")
    return int(a), int(b) + 1


def parse_cube(s):
    xs_str, ys_str, zs_str = [c.split("=")[1] for c in s.split(",")]

    x1, x2 = parse_range(xs_str)
    y1, y2 = parse_range(ys_str)
    z1, z2 = parse_range(zs_str)

    p1 = x1, y1, z1
    p2 = x2, y2, z2

    return Cube(p1, p2)


def split_axis(a1, a2, b1, b2):
    assert a1 <= b1 <= b2 <= a2

    if a1 < b1:
        yield a1, b1

    yield b1, b2

    if b2 < a2:
        yield b2, a2


def main():
    steps = []

    for line in sys.stdin:
        on_str, cube_str = line.split()

        on = on_str == "on"
        cube = parse_cube(cube_str)
        steps.append((on, cube))

    x1 = min(x for on, cube in steps for x, y, z in [cube.p1] if on)
    y1 = min(y for on, cube in steps for x, y, z in [cube.p1] if on)
    z1 = min(z for on, cube in steps for x, y, z in [cube.p1] if on)

    x2 = max(x for on, cube in steps for x, y, z in [cube.p2] if on)
    y2 = max(y for on, cube in steps for x, y, z in [cube.p2] if on)
    z2 = max(z for on, cube in steps for x, y, z in [cube.p2] if on)

    p1 = x1, y1, z1
    p2 = x2, y2, z2

    bounds = Cube(p1, p2)

    def solve(parent, i):
        if i == -1:
            return 0

        on, cube = steps[i]
        cube = cube & parent

        if not cube:
            return solve(parent, i - 1)

        result = on * cube.volume()

        for child in parent - cube:
            result += solve(child, i - 1)

        return result

    print(solve(bounds, len(steps) - 1))


if __name__ == "__main__":
    main()
