#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
inline void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << "}\n";
}
template <typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}\n";
}
const int N = 1000001;
int n, sz = 1;
string str;
struct segt {
  int mn, mx, lazy;
} st[N << 2];
inline void propagate(int x) {
  int &t = st[x].lazy;
  st[x << 1].mn += t;
  st[x << 1].mx += t;
  st[x << 1].lazy += t;
  st[x << 1 | 1].mn += t;
  st[x << 1 | 1].mx += t;
  st[x << 1 | 1].lazy += t;
  t = 0;
}
void update(int u, int v, int val, int x = 1, int l = 1, int r = sz) {
  if (u > r || v < l) return;
  if (u <= l && r <= v) {
    st[x].mn += val;
    st[x].mx += val;
    st[x].lazy += val;
    return;
  }
  int mid = l + r >> 1;
  propagate(x);
  update(u, v, val, x << 1, l, mid);
  update(u, v, val, x << 1 | 1, mid + 1, r);
  st[x].mn = min(st[x << 1].mn, st[x << 1 | 1].mn);
  st[x].mx = max(st[x << 1].mx, st[x << 1 | 1].mx);
}
int findLast(int x = 1, int l = 1, int r = sz) {
  if (l == r) return st[x].mx;
  propagate(x);
  return findLast(x << 1 | 1, (l + r >> 1) + 1, r);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> str;
  for (int i = 0, _n = (n); i < _n; ++i)
    if (str[i] == 'R') ++sz;
  str = ' ' + str;
  string s(n + 1, ' ');
  int pos = 1;
  for (int i = 1, _n = (n); i <= _n; ++i) {
    if (str[i] == 'L' && pos > 1)
      --pos;
    else if (str[i] == 'R')
      ++pos;
    else if ('a' <= str[i] && str[i] <= 'z') {
      if (s[pos] == '(')
        update(pos, sz, -1);
      else if (s[pos] == ')')
        update(pos, sz, 1);
      s[pos] = str[i];
    } else if (str[i] == '(') {
      if (s[pos] == ')')
        update(pos, sz, 2);
      else if (('a' <= s[pos] && s[pos] <= 'z') || s[pos] == ' ')
        update(pos, sz, 1);
      s[pos] = str[i];
    } else if (str[i] == ')') {
      if (s[pos] == '(')
        update(pos, sz, -2);
      else if (('a' <= s[pos] && s[pos] <= 'z') || s[pos] == ' ')
        update(pos, sz, -1);
      s[pos] = str[i];
    }
    if (st[1].mn >= 0 && !findLast())
      cout << st[1].mx << ' ';
    else
      cout << -1 << ' ';
  }
  return 0;
}
