#include <bits/stdc++.h>
using namespace std;
const int maxn = 250000;
bool vis[maxn];
int sk[maxn];
int ll[maxn], rr[maxn];
char s[maxn];
int n;
struct node {
  int u, v, val;
};
bool operator<(const node a, const node b) {
  if (a.val != b.val) return a.val > b.val;
  return a.u > b.u;
}
priority_queue<node> q;
int main() {
  while (cin >> n) {
    node tmp;
    memset(s, 0, sizeof s);
    int num = 0;
    scanf("%s", s + 1);
    for (int i = 1; i <= n; i++) {
      ll[i] = i - 1;
      rr[i] = i + 1;
      if (s[i] == 'B') num += 1;
    }
    num = (num < n - num) ? num : n - num;
    for (int i = 1; i <= n; i++) scanf("%d", &sk[i]);
    while (!q.empty()) q.pop();
    for (int i = 1; i < n; i++) {
      if (s[i] != s[i + 1]) {
        tmp.u = i;
        tmp.v = i + 1;
        tmp.val = abs(sk[i] - sk[i + 1]);
        q.push(tmp);
      }
    }
    memset(vis, 0, sizeof vis);
    printf("%d\n", num);
    while (num--) {
      while (!q.empty()) {
        tmp = q.top();
        q.pop();
        if (!vis[tmp.u] && !vis[tmp.v]) {
          printf("%d %d\n", tmp.u, tmp.v);
          vis[tmp.u] = 1;
          vis[tmp.v] = 1;
          break;
        }
      }
      int a = ll[tmp.u];
      int b = rr[tmp.v];
      rr[a] = b;
      ll[b] = a;
      tmp.u = a;
      tmp.v = b;
      tmp.val = abs(sk[a] - sk[b]);
      if (a > 0 && b <= n && s[a] != s[b]) q.push(tmp);
    }
  }
  return 0;
}
