def solve(S):
N = len(S)
# Initialize dp array with infinity
dp = [float('inf')] * (N + 1)
dp[0] = 0 # 0 components requires 0 length string
# Dictionary to store the lengths of shortest strings for each number of components
for length in range(1, N + 1):
for start in range(N - length + 1):
substring = S[start:start + length]
last_index = start
components = 1 # Start with one component
# Create bridges based on the substring
for j in range(1, length):
current_index = start + j
# If the current character matches the previous one in the substring
if S[last_index] == S[current_index]:
continue
else:
components += 1
last_index = current_index
# Update the dp array
dp[components] = min(dp[components], length)
# Prepare the result array
result = []
for k in range(1, N + 1):
result.append(dp[k] if dp[k] != float('inf') else 0)
return result
def main():
import sys
input = sys.stdin.read
S = input().strip()
result = solve(S)
print(" ".join(map(str, result)))
if __name__ == "__main__":
main()
ZGVmIHNvbHZlKFMpOgogICAgTiA9IGxlbihTKQogICAgIyBJbml0aWFsaXplIGRwIGFycmF5IHdpdGggaW5maW5pdHkKICAgIGRwID0gW2Zsb2F0KCdpbmYnKV0gKiAoTiArIDEpCiAgICBkcFswXSA9IDAgICMgMCBjb21wb25lbnRzIHJlcXVpcmVzIDAgbGVuZ3RoIHN0cmluZwoKICAgICMgRGljdGlvbmFyeSB0byBzdG9yZSB0aGUgbGVuZ3RocyBvZiBzaG9ydGVzdCBzdHJpbmdzIGZvciBlYWNoIG51bWJlciBvZiBjb21wb25lbnRzCiAgICBmb3IgbGVuZ3RoIGluIHJhbmdlKDEsIE4gKyAxKToKICAgICAgICBmb3Igc3RhcnQgaW4gcmFuZ2UoTiAtIGxlbmd0aCArIDEpOgogICAgICAgICAgICBzdWJzdHJpbmcgPSBTW3N0YXJ0OnN0YXJ0ICsgbGVuZ3RoXQogICAgICAgICAgICBsYXN0X2luZGV4ID0gc3RhcnQKICAgICAgICAgICAgY29tcG9uZW50cyA9IDEgICMgU3RhcnQgd2l0aCBvbmUgY29tcG9uZW50CiAgICAgICAgICAgIAogICAgICAgICAgICAjIENyZWF0ZSBicmlkZ2VzIGJhc2VkIG9uIHRoZSBzdWJzdHJpbmcKICAgICAgICAgICAgZm9yIGogaW4gcmFuZ2UoMSwgbGVuZ3RoKToKICAgICAgICAgICAgICAgIGN1cnJlbnRfaW5kZXggPSBzdGFydCArIGoKICAgICAgICAgICAgICAgICMgSWYgdGhlIGN1cnJlbnQgY2hhcmFjdGVyIG1hdGNoZXMgdGhlIHByZXZpb3VzIG9uZSBpbiB0aGUgc3Vic3RyaW5nCiAgICAgICAgICAgICAgICBpZiBTW2xhc3RfaW5kZXhdID09IFNbY3VycmVudF9pbmRleF06CiAgICAgICAgICAgICAgICAgICAgY29udGludWUKICAgICAgICAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICAgICAgICAgY29tcG9uZW50cyArPSAxCiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIGxhc3RfaW5kZXggPSBjdXJyZW50X2luZGV4CiAgICAgICAgICAgIAogICAgICAgICAgICAjIFVwZGF0ZSB0aGUgZHAgYXJyYXkKICAgICAgICAgICAgZHBbY29tcG9uZW50c10gPSBtaW4oZHBbY29tcG9uZW50c10sIGxlbmd0aCkKCiAgICAjIFByZXBhcmUgdGhlIHJlc3VsdCBhcnJheQogICAgcmVzdWx0ID0gW10KICAgIGZvciBrIGluIHJhbmdlKDEsIE4gKyAxKToKICAgICAgICByZXN1bHQuYXBwZW5kKGRwW2tdIGlmIGRwW2tdICE9IGZsb2F0KCdpbmYnKSBlbHNlIDApCiAgICAKICAgIHJldHVybiByZXN1bHQKCmRlZiBtYWluKCk6CiAgICBpbXBvcnQgc3lzCiAgICBpbnB1dCA9IHN5cy5zdGRpbi5yZWFkCiAgICBTID0gaW5wdXQoKS5zdHJpcCgpCiAgICAKICAgIHJlc3VsdCA9IHNvbHZlKFMpCiAgICBwcmludCgiICIuam9pbihtYXAoc3RyLCByZXN1bHQpKSkKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICBtYWluKCk=