#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int maxn = 1e6;
pair<int, int> seg[4 * maxn];
int mark[maxn], lazy[4 * maxn];
void push(int index, int left, int right) {
  seg[index].first += lazy[index];
  seg[index].second += lazy[index];
  if (left != right) {
    lazy[2 * index] += lazy[index];
    lazy[2 * index + 1] += lazy[index];
  }
  lazy[index] = 0;
}
void update(int index, int left, int right, int lo, int hi, int val) {
  push(index, left, right);
  if (lo > right || hi < lo) return;
  if (lo <= left && right <= hi) {
    lazy[index] += val;
    push(index, left, right);
    return;
  }
  int mid = (left + right) / 2;
  update(2 * index, left, mid, lo, hi, val);
  update(2 * index + 1, mid + 1, right, lo, hi, val);
  seg[index].first = max(seg[2 * index].first, seg[2 * index + 1].first);
  seg[index].second = min(seg[2 * index].second, seg[2 * index + 1].second);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cursor = 0, sum = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == 'R')
      ++cursor;
    else if (s[i] == 'L')
      cursor = max(0, cursor - 1);
    else if (s[i] == '(' && mark[cursor] != 1) {
      update(1, 0, maxn, cursor, maxn, 1 - mark[cursor]);
      sum += 1 - mark[cursor];
      mark[cursor] = 1;
    } else if (s[i] == ')' && mark[cursor] != -1) {
      update(1, 0, maxn, cursor, maxn, -1 - mark[cursor]);
      sum += -1 - mark[cursor];
      mark[cursor] = -1;
    } else if (isalpha(s[i]) && mark[cursor]) {
      update(1, 0, maxn, cursor, maxn, -mark[cursor]);
      sum += -mark[cursor];
      mark[cursor] = 0;
    }
    cout << (sum == 0 && seg[1].second == 0 ? seg[1].first : -1) << ' ';
  }
  cout << '\n';
  return 0;
}
