#include <bits/stdc++.h>
using namespace std;
struct segment {
  long size;
  char c;
};
string a;
string b;
vector<segment> seg_a;
vector<segment> seg_b;
vector<pair<long, long>> swaps;
bool swapped;
vector<segment> read_segments(const string& s) {
  vector<segment> segments;
  for (long i = 0; i < s.size(); ++i) {
    if (segments.empty() || s[i] != segments.back().c) {
      segments.push_back({0, s[i]});
    }
    ++segments.back().size;
  }
  reverse(segments.begin(), segments.end());
  return segments;
}
void push_segment(vector<segment>& v, const segment& s) {
  if (v.empty() || v.back().c != s.c) {
    v.push_back(s);
  } else {
    v.back().size += s.size;
  }
}
void make_swap(long cut_a, long cut_b) {
  pair<long, long> s = {0l, 0l};
  vector<segment> tail_a;
  tail_a.reserve(cut_a);
  while (tail_a.size() < cut_a) {
    s.first += seg_a.back().size;
    tail_a.push_back(seg_a.back());
    seg_a.pop_back();
  }
  vector<segment> tail_b;
  tail_b.reserve(cut_b);
  while (tail_b.size() < cut_b) {
    s.second += seg_b.back().size;
    tail_b.push_back(seg_b.back());
    seg_b.pop_back();
  }
  while (tail_a.size() > 0) {
    push_segment(seg_b, tail_a.back());
    tail_a.pop_back();
  }
  while (tail_b.size() > 0) {
    push_segment(seg_a, tail_b.back());
    tail_b.pop_back();
  }
  swaps.push_back(s);
}
int main() {
  cin >> a >> b;
  seg_a = read_segments(a);
  seg_b = read_segments(b);
  if (seg_a.size() <= 1 && seg_b.size() <= 1) {
    cout << "0\n";
    return 0;
  }
  swapped = (seg_b.size() > seg_a.size());
  if (swapped) {
    swap(seg_a, seg_b);
  }
  {
    bool same = (seg_a.back().c == seg_b.back().c);
    pair<long, long> s = {0l, 0l};
    long diff_size = seg_a.size() - seg_b.size();
    if (same && diff_size % 4 == 3) {
      long k = lround(static_cast<double>(diff_size - 1.0) / 4.0);
      make_swap(2 * k, 1);
      make_swap(1, 0);
    } else if (same || seg_b.size() <= 1) {
      long k = lround(static_cast<double>(diff_size - 1.0) / 4.0);
      make_swap(2 * k + 1, same ? 0 : 1);
    } else {
      long k = lround(static_cast<double>(diff_size) / 4.0);
      make_swap(2 * k + 1, 1);
    }
  }
  while (seg_a.size() > 1 || seg_b.size() > 1) {
    make_swap(1, 1);
  }
  cout << swaps.size() << '\n';
  for (auto& s : swaps) {
    if (swapped) {
      cout << s.second << ' ' << s.first << '\n';
    } else {
      cout << s.first << ' ' << s.second << '\n';
    }
  }
}
