#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chkmin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
int readint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, ns, nt;
char s[400005], t[400005], ts[400005], tt[400005];
pair<int, int> ps[400005], pt[400005];
vector<pair<int, int> > ans;
void perform(int x, int y) {
  for (int i = y + 1; i <= n - x + y; i++) ts[i] = s[i + x - y];
  for (int i = x + 1; i <= m - y + x; i++) tt[i] = t[i + y - x];
  for (int i = 1; i <= x; i++) tt[i] = s[i];
  for (int i = 1; i <= y; i++) ts[i] = t[i];
  swap(s, ts), swap(t, tt);
  int tn = n - x + y, tm = m + x - y;
  n = tn, m = tm;
}
void init() {
  ns = nt = 0;
  for (int i = 2; i <= n; i++)
    if (s[i] != s[i - 1]) ps[++ns] = make_pair(i - 1, s[i - 1] - 'a');
  ps[++ns] = make_pair(n, s[n] - 'a');
  for (int i = 2; i <= m; i++)
    if (t[i] != t[i - 1]) pt[++nt] = make_pair(i - 1, t[i - 1] - 'a');
  pt[++nt] = make_pair(m, t[m] - 'a');
}
int main() {
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  n = strlen(s + 1), m = strlen(t + 1);
  int as = s[1] - 'a', at = t[1] - 'a';
  init();
  if (ns == 1 && as == at && nt % 2 == 0 && (nt / 2 & 1)) {
    int l = nt / 2;
    ans.push_back(make_pair(0, pt[l].first));
    perform(0, pt[l].first);
    init();
  } else if (nt == 1 && as == at && ns % 2 == 0 && (ns / 2 & 1)) {
    int l = ns / 2;
    ans.push_back(make_pair(ps[l].first, 0));
    perform(ps[l].first, 0);
    init();
  }
  if (abs(ns - nt) > 2) {
    if (ns < nt) {
      int tmp = (nt - ns + 1) / 2;
      if ((tmp ^ (as == at)) & 1) tmp--;
      ans.push_back(make_pair(ps[1].first, pt[tmp + 1].first));
      perform(ps[1].first, pt[tmp + 1].first);
      init();
    } else {
      int tmp = (ns - nt + 1) / 2;
      if ((tmp ^ (as == at)) & 1) tmp--;
      ans.push_back(make_pair(ps[tmp + 1].first, pt[1].first));
      perform(ps[tmp + 1].first, pt[1].first);
      init();
    }
  }
  if (ns >= nt && s[1] == t[1]) {
    ans.push_back(make_pair(ps[1].first, 0));
    perform(ps[1].first, 0);
    init();
  } else if (ns < nt && s[1] == t[1]) {
    ans.push_back(make_pair(0, pt[1].first));
    perform(0, pt[1].first);
    init();
  }
  int vals = 0, valt = 0;
  for (int i = 1; i < min(ns, nt) + (abs(ns - nt) == 2); i++) {
    ans.push_back(make_pair(ps[i].first + vals, pt[i].first + valt));
    int tmp = pt[i].first + valt - ps[i].first - vals;
    vals += tmp, valt -= tmp;
  }
  if (ns < nt)
    ans.push_back(make_pair(ps[ns].first + vals, pt[nt - 1].first + valt));
  else if (ns > nt)
    ans.push_back(make_pair(ps[ns - 1].first + vals, pt[nt].first + valt));
  printf("%d\n", ans.size());
  for (auto x : ans) printf("%d %d\n", x.first, x.second);
  return 0;
}
