#include #define ONLINE_JUDGE using namespace std; int n; string s; vector passwords; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); passwords.clear(); #ifdef ONLINE_JUDGE freopen("password.in", "r", stdin); freopen("password.out", "w", stdout); #endif // ONLINE_JUDGE cin >> n; cin >> s; int i, j; int ml = 1, curl = 1; int br[10]; string pass; memset(br, 0, sizeof(br)); for (i = 0; i < n - 1; i++) { br[s[i] - '0']++; if (s[i] == s[i + 1]) curl++; else { if (curl > ml) { ml = curl; curl = 1; } } } br[s[s.size() - 1] - '0']++; if (curl > ml) ml = curl; for (i = 0; i < 10; i++) { if (br[i] == ml) { pass = ""; for (j = 0; j < ml; j++) { pass = pass + char(i + '0'); } passwords.push_back(pass); } } sort(passwords.begin(), passwords.end()); cout << passwords.size() << '\n'; for (i = 0; i < passwords.size(); i++) { cout << passwords[i] << '\n'; } return 0; }