#!/usr/bin/perl

use v5.30;
use strict;

chomp (my $stream = <>);

1 while $stream =~ s/<[^!>]*!./</;
1 while $stream =~ s/<[^>]*?>//;

my $sum;
my $depth = 0;
for my $c (split //, $stream) {
	if ($c eq '{') {
		$depth++;
	} elsif ($c eq '}') {
		$sum += $depth--;
	}
}

say $sum;
