#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
vector<int> v1, v2, ps1, ps2;
string s1, s2, aux1, aux2;
vector<pair<int, int>> ans, aux;
void addLast(string &str, vector<int> &pos) {
  for (int i = 0, j = 0; i < str.length(); i = j) {
    while (j < str.length() and str[j] == str[i]) {
      ++j;
    }
    pos.push_back(j - 1);
  }
}
inline int siz(vector<int> &pos, int p) {
  if (p < 0 or !pos.size()) {
    return 0;
  }
  if (p >= pos.size()) {
    return pos.back() + 1;
  }
  return pos[p] + 1;
}
void solve(string &str1, string &str2, vector<pair<int, int>> &ans) {
  ps1.clear();
  ps2.clear();
  addLast(str1, ps1);
  addLast(str2, ps2);
  int c1 = (int)max(ps1.size() - (ps1.size() and str1.back() == 'a'),
                    ps2.size() - (ps2.size() and str2.back() == 'b')),
      c2 = (int)max(ps1.size() - (ps1.size() and str1.back() == 'b'),
                    ps2.size() - (ps2.size() and str2.back() == 'a'));
  if (c1 <= c2) {
    int p1 = (int)ps1.size() - 1, p2 = (int)ps2.size() - 1;
    if (ps1.size() and str1.back() == 'a') {
      --p1;
    }
    if (ps2.size() and str2.back() == 'b') {
      --p2;
    }
    for (bool ok = false; p1 >= 0 or p2 >= 0; --p1, --p2, ok ^= true) {
      ans.push_back(!ok ? make_pair(siz(ps1, p1), siz(ps2, p2))
                        : make_pair(siz(ps2, p2), siz(ps1, p1)));
    }
  } else {
    int p1 = (int)ps1.size() - 1, p2 = (int)ps2.size() - 1;
    if (ps1.size() and str1.back() == 'b') {
      --p1;
    }
    if (ps2.size() and str2.back() == 'a') {
      --p2;
    }
    for (bool ok = false; p1 >= 0 or p2 >= 0; --p1, --p2, ok ^= true) {
      ans.push_back(!ok ? make_pair(siz(ps1, p1), siz(ps2, p2))
                        : make_pair(siz(ps2, p2), siz(ps1, p1)));
    }
  }
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s1 >> s2;
  bool ok = false;
  addLast(s1, v1);
  addLast(s2, v2);
  if (v1.size() > v2.size()) {
    swap(v1, v2);
    swap(s1, s2);
    ok = true;
  }
  solve(s1, s2, ans);
  for (int i = -1; i <= min(3, (int)v1.size()); ++i) {
    int x = (int)max(-1, (int)((v2.size() - v1.size()) / 2 - 3)),
        y = (int)min(v2.size(), (v2.size() - v1.size()) / 2 + 3);
    for (int j = x; j <= y; ++j) {
      int p1 = siz(v1, i), p2 = siz(v2, j);
      aux2 = s1.substr(0, p1) + s2.substr(p2);
      aux1 = s2.substr(0, p2) + s1.substr(p1);
      aux.clear();
      aux.push_back(make_pair(p1, p2));
      solve(aux1, aux2, aux);
      if (aux.size() < ans.size()) {
        ans = aux;
      }
    }
  }
  cout << ans.size() << "\n";
  if (ok) {
    for (pair<int, int> &p : ans) {
      swap(p.first, p.second);
    }
  }
  for (pair<int, int> p : ans) {
    cout << p.first << " " << p.second << "\n";
  }
  return 0;
}
