#include <bits/stdc++.h>
using namespace std;
string s, t;
vector<pair<int, int> > ans1;
vector<pair<int, int> > ans2;
vector<int> v1;
vector<int> v2;
vector<int> v3;
vector<int> v4;
void solve1(vector<pair<int, int> >& ans, int a, int b) {
  if (v1.size() == 0) v1.push_back(0);
  if (v2.size() == 0) v2.push_back(0);
  while (a > 0) {
    v3.push_back(v1.back());
    v1.pop_back();
    a--;
  }
  while (b > 0) {
    v4.push_back(v2.back());
    v2.pop_back();
    b--;
  }
  int val1 = v1.back();
  int val2 = v2.back();
  ans.emplace_back(val1, val2);
  v1.pop_back();
  v2.pop_back();
  swap(v1, v2);
  while (v3.size() > 0) {
    v1.push_back(v3.back() - val1 + val2);
    v3.pop_back();
  }
  while (v4.size() > 0) {
    v2.push_back(v4.back() + val1 - val2);
    v4.pop_back();
  }
}
void solve(vector<pair<int, int> >& ans) {
  int i;
  for (i = 0; i < s.size() - 1; i++) {
    if (s[i] != s[i + 1]) v1.push_back(i + 1);
  }
  for (i = 0; i < t.size() - 1; i++) {
    if (t[i] != t[i + 1]) v2.push_back(i + 1);
  }
  while (1) {
    if ((v1.size() > 1 && v2.size() > 1) ||
        ((v1.size() > 0 || v2.size() > 0) && v1.size() < 3 && v2.size() < 3))
      solve1(ans, 0, 0);
    else if (v1.size() > 2)
      solve1(ans, 2, 0);
    else if (v2.size() > 2)
      solve1(ans, 0, 2);
    else
      break;
  }
}
int main() {
  int i;
  cin >> s;
  cin >> t;
  s += 'a';
  t += 'b';
  solve(ans1);
  s[s.size() - 1] = 'b';
  t[t.size() - 1] = 'a';
  solve(ans2);
  if (ans1.size() < ans2.size()) {
    printf("%d\n", ans1.size());
    for (i = 0; i < ans1.size(); i++)
      printf("%d %d\n", ans1[i].first, ans1[i].second);
  } else {
    printf("%d\n", ans2.size());
    for (i = 0; i < ans2.size(); i++)
      printf("%d %d\n", ans2[i].first, ans2[i].second);
  }
  return 0;
}
