// Author: Ivan Kazmenko (gassa@mail.ru)
#include <cassert>
#include <string>
#include "testlib.h"

using namespace std;

int main (void)
{
 setName ("validator for problem \"bracket-expression\"");

 registerValidation ();

 string s = inf.readString ("[()]{0,40}");
 inf.readEof ();

 int d = 0;
 for (int i = 0; i < (int) s.size (); i++)
 {
  if (s[i] == '(') d++;
  else if (s[i] == ')') d--;
  else assert (false);
  ensure (d >= 0);
 }
 ensure (d == 0);

 return 0;
}
