#include <bits/stdc++.h>
using namespace std;
template <class _Tp>
_Tp gcd(_Tp a, _Tp b) {
  return (b == 0) ? (a) : (gcd(b, a % b));
}
const long long Inf = 1000000000000000000ll;
const int inf = 1000000000;
string s, t;
vector<pair<int, int> > ans1, ans2;
vector<int> v1, v2, v3, v4;
void solvel(vector<pair<int, int> > &ans, int a, int b) {
  if (!v1.size()) v1.push_back(0);
  if (!v2.size()) v2.push_back(0);
  while (a--) {
    v3.push_back(v1.back());
    v1.pop_back();
  }
  while (b--) {
    v4.push_back(v2.back());
    v2.pop_back();
  }
  int val1 = v1.back(), val2 = v2.back();
  v1.pop_back();
  v2.pop_back();
  ans.emplace_back(val1, val2);
  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) {
  for (int i = 1; i < s.size(); i++)
    if (s[i - 1] != s[i]) v1.push_back(i);
  for (int i = 1; i < t.size(); i++)
    if (t[i - 1] != t[i]) v2.push_back(i);
  while (1) {
    if ((v1.size() > 1 && v2.size() > 1) ||
        ((v1.size() || v2.size()) && v1.size() < 3 && v2.size() < 3))
      solvel(ans, 0, 0);
    else if (v1.size() > 2)
      solvel(ans, 2, 0);
    else if (v2.size() > 2)
      solvel(ans, 0, 2);
    else
      break;
  }
}
int main() {
  cin >> s >> t;
  s += 'a';
  t += 'b';
  solve(ans1);
  s[s.size() - 1] = 'b';
  t[t.size() - 1] = 'a';
  solve(ans2);
  if (ans1.size() > ans2.size()) swap(ans1, ans2);
  printf("%d\n", ans1.size());
  for (pair<int, int> i : ans1) printf("%d %d\n", i.first, i.second);
  return 0;
}
