#include <iostream>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <cassert>
using namespace std;

#define MAIN main
#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) 
#define CEXPR( LL , BOUND , VALUE ) constexpr const LL BOUND = VALUE 
#define CIN( LL , A ) LL A; cin >> A 
#define ASSERT( A , MIN , MAX ) assert( MIN <= A && A <= MAX ) 
#define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) 
#define FOREQINV( VAR , INITIAL , FINAL ) for( TYPE_OF( INITIAL ) VAR = INITIAL ; VAR >= FINAL ; VAR -- ) 
#define QUIT return 0 
#define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT 


int g( const string& H )
{
  CEXPR( int , length , 100000 );
  int size = H.size();
  ASSERT( size , 2 , length );
  static const string L = "(";
  int count_mex = 0;
  bool exceptional = false;
  int count_mex_exceptional = 0;
  int height = 0;
  FOREQINV( i , size - 1 , 0 ){
    if( H.substr( i , 1 ) == L ){
      height--;
      if( height == -1 ){
	break;
      } else if( height > 0 ? H.substr( i - 1 , 1 ) == L : false ){
	exceptional = true;
	height--;
	i--;
	while( height > 0 && i > 0 ? H.substr( i - 1 , 1 ) == L : false ){
	  count_mex_exceptional++;
	  height--;
	  i--;
	}
	break;
      } else {
	if( height > 0 ){
	  height = 1;
	}
	count_mex++;
      }
    } else {
      height++;
    }
  }
  if( exceptional ){
    if( count_mex == 0 ){
      return count_mex_exceptional % 2 == 0 ? 2 : 3;
    } else {
      return count_mex % 2 == 0 ? 1 : 0;
    }
  }
  return count_mex % 2 == 0 ? 0 : 1;
}

int MAIN()
{
  UNTIE;
  CIN( string , H );
  RETURN( g( H ) == 0 ? 1 : 0 );
}