#include <bits/stdc++.h>
using namespace std;
int swaps(const string a) {
  int swaps = 0;
  for (int i = 0; i < a.size() - 1; i++)
    if (a[i] != a[i + 1]) swaps++;
  return swaps;
}
int getKthSwap(const string a, int k) {
  int i = a.size() - 2;
  if (k == 0) return a.size() - 1;
  while (i > 0) {
    if (a[i] != a[i + 1]) k--;
    if (k == 0) return i;
    i--;
  }
  return -1;
}
vector<pair<int, int>> solve(string a, string b, int p, int q) {
  if (p < 0) p = 0;
  if (q < 0) q = 0;
  vector<pair<int, int>> sol;
  p = getKthSwap(a, p);
  q = getKthSwap(b, q);
  p++;
  q++;
  string aSuf = string(a, p, a.size());
  string bSuf = string(b, q, b.size());
  a = string(a, 0, p) + bSuf;
  b = string(b, 0, q) + aSuf;
  if (a.empty() || b.empty()) return {{-1, -1}};
  sol.push_back({p - 1, q - 1});
  bool swapped = true;
  int n = a.size();
  int m = b.size();
  char lookA = 'b', lookB = 'a';
  if (a[n - 1] == 'b') swap(lookA, lookB);
  int i = n - 1, j = m - 1;
  while (i >= 0 || j >= 0) {
    while (i >= 0 && a[i] != lookA) i--;
    while (j >= 0 && b[j] != lookB) j--;
    if (i == -1 && j == -1) break;
    if (swapped)
      sol.push_back({j, i});
    else
      sol.push_back({i, j});
    swapped = !swapped;
    swap(lookA, lookB);
  }
  return sol;
}
int main() {
  string a, b;
  cin >> a;
  cin >> b;
  bool swapped = false;
  if (swaps(a) < swaps(b)) {
    swapped = true;
    swap(a, b);
  }
  int swapsA = swaps(a);
  int swapsB = swaps(b);
  if (swapsA == swapsB && swapsA == 0) {
    cout << "0\n";
    return 0;
  }
  int middle = (swapsA + swapsB + 1) / 2;
  int delta = swapsA - middle;
  vector<pair<int, int>> sol = {{-1, -1}};
  for (int i = delta - 3; i < delta + 3; i++)
    for (int j = 0; j < 3; j++) {
      auto tmp = solve(a, b, i, j);
      if (sol[0].first == -1) sol = tmp;
      if (tmp.size() == 0) {
        sol = tmp;
        break;
      }
      if (tmp.size() < sol.size() && tmp[0].first != -1) sol = tmp;
    }
  cout << sol.size() << endl;
  for (auto p : sol) {
    if (!swapped)
      cout << p.first + 1 << " " << p.second + 1 << endl;
    else
      cout << p.second + 1 << " " << p.first + 1 << endl;
  }
  return 0;
}
