import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Task2 {
public static void main(String[] args) {
String text = "ZAAABBCCDDDD";
Matcher m = Pattern.compile("(.)\\1+").matcher(text);
while (m.find()) {
String sub = m.group();
System.out.println(sub + sub.length ());
}
}
}