#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define d(a,b,c) cout<<a<<" "<<b<<" "<<c<<'\n'
#define IO ios_base::sync_with_stdio(0);cin.tie(0);


int main()
{
    IO;
	string s; cin >> s;
	char lstc = ' ';
	int lst = 0;
	ll ans = 0;
	int cnt[26];
	memset(cnt, 0, sizeof(cnt));
	
	for(int i = s.size()-1, cntin = 0; i >= 0; i--)
	{
		cnt[s[i]-'a']++;
		cntin++;
		if(i < s.size()-1 and s[i] == s[i+1])
		{
			for(int j = 0; j < 26; j++)
			{
				if(int(s[i]-'a') != j)
				{
					ans += cnt[j];
					cnt[j] = 0;
				}
				else cnt[j] = cntin;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const int INF = 1001001001;

int N;
vector<int> A;
vector<pair<int,int>> X;
vector<int> Side;
vector<int> Stacks[2];
string ans;

int main(){
  cin >> N; N*=2;
  vector<int> A(N); rep(i,N) cin >> A[i];
  rep(i,N) X.push_back({A[i],i});
  sort(X.begin(),X.end());
  Side.resize(N);
  rep(i,N) Side[X[i].second] = i / (N/2);
  ans = string(N,'.');
  rep(i,N){
    if(Stacks[1-Side[i]].empty()){
      Stacks[Side[i]].push_back(i);
    }
    else{
      int opposite = Stacks[1-Side[i]].back();
      Stacks[1-Side[i]].pop_back();
      ans[opposite] = '(';
      ans[i] = ')';
    }
  }
  cout << ans << "\n";
  return 0;
}