IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her entertainment more interesting.

Today, when IA looked at the fridge, she noticed that the word formed by magnets is really messy. "It would look much better when I'll swap some of them!" — thought the girl — "but how to do it?". After a while, she got an idea. IA will look at all prefixes with lengths from $1$ to the length of the word and for each prefix she will either reverse this prefix or leave it as it is. She will consider the prefixes in the fixed order: from the shortest to the largest. She wants to get the lexicographically smallest possible word after she considers all prefixes. Can you help her, telling which prefixes should be chosen for reversing?

A string $a$ is lexicographically smaller than a string $b$ if and only if one of the following holds: $a$ is a prefix of $b$, but $a \ne b$; in the first position where $a$ and $b$ differ, the string $a$ has a letter that appears earlier in the alphabet than the corresponding letter in $b$.


-----Input-----

The first and the only line contains a string $s$ ($1 \le |s| \le 1000$), describing the initial string formed by magnets. The string $s$ consists only of characters 'a' and 'b'.


-----Output-----

Output exactly $|s|$ integers. If IA should reverse the $i$-th prefix (that is, the substring from $1$ to $i$), the $i$-th integer should be equal to $1$, and it should be equal to $0$ otherwise.

If there are multiple possible sequences leading to the optimal answer, print any of them.


-----Examples-----
Input
bbab

Output
0 1 1 0

Input
aaaaa

Output
1 0 0 0 1



-----Note-----

In the first example, IA can reverse the second and the third prefix and get a string "abbb". She cannot get better result, since it is also lexicographically smallest string obtainable by permuting characters of the initial string.

In the second example, she can reverse any subset of prefixes — all letters are 'a'.

Source: codeforces | Difficulty: MEDIUM
Tags: Greedy algorithms

Implementation

Constructive algorithms


Solutions:
def solve(s):
	i = s.rfind('a')
	if i == -1:
		return s
s = input()
n = len(s)
ans = ['0' for i in range(n)]
for i in range(n - 1):
	if s[0] == s[i + 1]:
		s = s[i::-1] + s[i + 1:]
		ans[i] = '1'
if s[-1] == 'a':
	ans[-1] = '1'
print(' '.join(ans))


s = input()
a = [0]
if len(s) == 1:
	print(0)
	exit(0)
for i in range(1, len(s) - 1):
	if s[i] != s[i + 1]:
		a.append(1)
	else:
		a.append(0)
if s[-1] == 'b':
	a.append(0)
else:
	a.append(1)
print(*a)


s = input()
if s[0] == 'a':
	swp = ['a', 'b']
else:
	swp = ['b', 'a']
ans = [0] * len(s)
for i in range(1, len(s)):
	if s[i] == swp[1] and s[i - 1] == swp[0]:
		ans[i - 1] = 1
		x = swp[1]
		swp[1] = swp[0]
		swp[0] = x
if s[-1] == 'a':
	ans[-1] = 1
print(*ans)


s = input()
n = len(s)
res = [0] * n
for i in range(1, n):
	if s[i] == 'a':
		res[i - 1] ^= 1
		res[i] = 1
print(*res)


st = input()
ans = ''
k = 0
while len(st) > k and st[k] == 'a':
	k += 1
	ans += '0 '
while len(st) > k and st[k] == 'b':
	k += 1
	ans += '0 '
for i in range(k, len(st)):
	if st[i - 1] != st[i]:
		ans += '1 '
	else:
		ans += '0 '
if st[-1] == 'a':
	ans += '1'
else:
	ans += '0'
ans = ans[2:]
print(ans)


from itertools import groupby
s = '#' + input()
l = len(s)
ans = [0] * l
for i in range(1, l):
	if s[i] == 'a':
		ans[i - 1] ^= 1
		ans[i] = 1
print(*ans[1:])


s = list(input())
n = len(s)
ans = [0 for i in range(n + 1)]
for i in range(1, n + 1):
	if s[i - 1] == 'a':
		ans[i - 1] ^= 1
		ans[i] = 1
for i in range(1, n + 1):
	print(ans[i], end=' ')
print('')


a = list(input())
a.append('b')
kek = []
for i in range(len(a) - 1):
	if a[i] == 'a' and a[i + 1] == 'b' or (a[i] == 'b' and a[i + 1] == 'a'):
		kek.append(1)
	else:
		kek.append(0)
print(*kek)


from math import *
a = list(input())
n = len(a)
k = ord(a[0])
ans = [0 for i in range(n)]
for i in range(1, n - 1):
	if a[i] != a[i + 1]:
		ans[i] = 1
if a[-1] == 'b':
	ans[-1] = 0
else:
	ans[-1] = 1
print(*ans)


s = input()
n = len(s)
min_str = ''.join(sorted(list(s)))
res = []
for i in range(n - 1, -1, -1):
	if not s[i] == min_str[i]:
		tail = min_str[i + 1:]
		s_lst = reversed(list(min_str[:i + 1]))
		new_s = ''.join(s_lst)
		min_str = new_s + tail
		res.append(1)
	else:
		res.append(0)
print(' '.join([str(x) for x in list(reversed(res))]))


def check(current, source_final_ch):
	if current[-1] != source_final_ch:
		current.reverse()
		return (1, current[:-1])
	return (0, current[:-1])

def calc(source):
	actions = []
	best = sorted(source)
	current = best
	for i in range(len(source)):
		res = check(current, source[-i - 1])
		(act, current) = res
		actions.insert(0, act)
	return actions

def get_ints():
	return [int(n) for n in input().split()]

def get_floats():
	return [float(n) for n in input().split()]

def seq2str(seq):
	return ' '.join((str(item) for item in seq))
s = input()
res = calc(list(s))
print(seq2str(res))


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a / gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 0
	right = len(a)
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)
s = input()
n = len(s)
ar = [0] * n
a = 0
for i in range(1, n):
	if s[i] == 'a':
		if a == 0:
			ar[i - 1] = 1
		if i == n - 1:
			ar[i] = 1
		elif s[i + 1] != 'a':
			ar[i] = 1
			a = 0
		else:
			a += 1
print(*ar)


import sys
import itertools
import math
M_PI = 3.141592653589793
s = input()
n = len(s)
ans = [0] * n
for i in range(1, n):
	if s[i] == 'a':
		ans[i - 1] = 1 - ans[i - 1]
		ans[i] = 1
print(' '.join([str(i) for i in ans]))


s = input()
for i in range(len(s) - 1):
	if s[i + 1] == s[0]:
		print(1, end=' ')
		s = s[i::-1] + s[i + 1::1]
	else:
		print(0, end=' ')
if s[0] == 'a':
	print(0)
else:
	print(1)


s = input().strip()
n = len(s)
ans = [0] * n
i = 0
while i < n:
	j = i + 1
	if s[i] == 'b':
		while j < n and s[j] == 'b':
			j += 1
		if j != n:
			ans[j - 1] = 1
			while j < n and s[j] == 'a':
				j += 1
			ans[j - 1] = 1
	i = j
print(*ans)


s = input()
ans = [0] * len(s)
for i in range(1, len(s) - 1):
	if s[0] == 'a' and s[i:i + 2] == 'ba' or (s[0] == 'b' and s[i:i + 2] == 'ab'):
		s = s[:i + 1][::-1] + s[i + 1:]
		ans[i] = 1
if s[-1] == 'a':
	s = s[::-1]
	ans[-1] = 1
print(' '.join((str(i) for i in ans)))


s = input()
n = len(s)
a = s.count('a')
s1 = ''
count = []
i = 0
while i < n:
	count.append(0)
	s1 = s1 + s[i]
	while i + count[-1] < n and s[i + count[-1]] == s[i]:
		count[-1] += 1
	i += count[-1]
nc = len(count)
if s1[nc - 1] == 'a':
	for i in range(nc):
		for j in range(1, count[i]):
			print(0, end=' ')
		print(1, end=' ')
else:
	bs = 0
	while bs + 1 <= n and s[-bs - 1] == 'b':
		bs += 1
	for i in range(nc - 1):
		for j in range(1, count[i]):
			print(0, end=' ')
		print(1, end=' ')
	for i in range(bs):
		print(0, end=' ')


s = input()
test = []
tot = []
for item in range(1, len(s)):
	pod = list(s[0:item])
	if pod[0] == s[item]:
		tot.append(1)
		pod.reverse()
		pod_1 = ''
		for elem in pod:
			pod_1 += elem
		s = pod_1 + s[item:]
	else:
		tot.append(0)
tot_1 = ''
if s[-1] == 'a':
	tot.append(1)
else:
	tot.append(0)
for item in tot:
	tot_1 += str(item) + ' '
print(tot_1[:-1])


s = input()
n = len(s)
ans = [0 for i in range(n)]
i = 0
while True:
	while i != n and s[i] == 'a':
		i += 1
	if i != 0:
		ans[i - 1] = 1
	if i == n:
		break
	while i != n and s[i] == 'b':
		i += 1
	if i == n:
		break
	else:
		ans[i - 1] = 1
for i in ans:
	print(i, end=' ')


s = input()
l = []
for i in range(1, len(s) + 1):
	if s[0] == 'b':
		if i == len(s) or (s[i - 1] == 'a' and s[i] == 'b'):
			l.append(1)
			s = s[:i][::-1] + s[i:]
		else:
			l.append(0)
	elif i < len(s) and s[i - 1] == 'b' and (s[i] == 'a'):
		l.append(1)
		s = s[:i][::-1] + s[i:]
	else:
		l.append(0)
for x in l:
	print(x, end=' ')
print()


import sys
input = sys.stdin.readline
mii = lambda : map(int, input().split())
s = input().strip()
a1 = ''
a2 = []
b1 = ''
b2 = []
for ch in s:
	got = [a1 + ch, b1 + ch, ch + a1[::-1], ch + b1[::-1]]
	arr = [a2 + [0], b2 + [0], a2 + [1], b2 + [1]]
	a3 = min(got)
	idx = got.index(a3)
	a4 = arr[idx]
	b3 = a3[::-1]
	b4 = arr[idx ^ 2]
	a1 = a3
	a2 = a4
	b1 = b3
	b2 = b4
print(' '.join(map(str, a2)))


def f(mag):
	if len(mag) == 1:
		return []
	elif mag[-1] == 'b':
		return f(mag[:-1])
	else:
		boi = len(mag)
		old = f(mag[:-1])
		if boi - 1 in old:
			old.pop()
			old.append(boi)
			return old
		else:
			old.append(boi - 1)
			old.append(boi)
			return old
string = input()
k = f(string)
out = ''
for i in range(len(string)):
	if i + 1 in k:
		out += '1 '
	else:
		out += '0 '
print(out[:-1])


a = input()
res = ['0'] * len(a)
i = 1
while i < len(a):
	if i > 1 and a[i - 1] != a[i]:
		res[i - 1] = '1'
	i += 1
if i != 1 and a[i - 1] == 'a':
	res[i - 1] = '1'
import sys
sys.stdout.write(' '.join(res))


s = input()
o = ['0'] * len(s)
a = s[0]
for i in range(1, len(s)):
	if a == s[i]:
		o[i - 1] = '1'
		a = s[i - 1]
if a == 'b':
	o[-1] = '1'
print(' '.join(o))


s = input()
n = len(s)
dp = [0 for i in range(n)]
i = 1
while i < n:
	if s[i] == 'a':
		dp[i - 1] = 1
		while i < n and s[i] == 'a':
			i += 1
		i -= 1
		dp[i] = 1
	i += 1
print(*dp)


s = input()
b = 1
up = len(s) - 1
out = [0] * len(s)
while up > -1:
	if b == 1:
		if s[up] == 'b':
			out[up] = 0
		else:
			out[up] = 1
			b = (b + 1) % 2
	elif s[up] == 'a':
		out[up] = 0
	else:
		out[up] = 1
		b = (b + 1) % 2
	up -= 1
ans = ''
for i in range(len(s)):
	ans += str(out[i]) + ' '
print(ans[:-1])


from itertools import product
from random import choice

def do_test(s):
	actions = []
	tmp = s[:]
	tmp = tmp.rstrip('b')
	build = []
	for (i, j) in enumerate(tmp):
		if j == 'b' and tmp[i + 1] == 'b':
			build.append(j)
			actions.append(0)
			continue
		if j == 'a' and i != len(tmp) - 1 and (tmp[i + 1] == 'a'):
			build.append(j)
			actions.append(0)
			continue
		actions.append(1)
		build.append(j)
		build.reverse()
	while len(actions) != len(s):
		actions.append(0)
	print(' '.join(map(str, actions)))

def do_brute(s):
	minim = -1
	for p in product([True, False], repeat=len(s)):
		tmp = []
		for (i, j) in enumerate(p):
			tmp.append(s[i])
			if j:
				tmp.reverse()
		r = ''.join(tmp)
		if minim == -1 or r < minim:
			minim = r
	return minim
s = input()
do_test(s)


import sys
import math

def main():
	s = next(sys.stdin).strip()
	s += 'b'
	res = [int(i != j) for (i, j) in zip(s, s[1:])]
	print(' '.join(map(str, res)))
main()


(s, out) = (list(input()), [])
last = s[0]
for i in range(len(s)):
	if i < len(s) - 1:
		if last == 'a' and s[i] == 'b' and (s[i + 1] == 'a'):
			out.append(1)
			last = 'b'
		elif last == 'b' and s[i] == 'a' and (s[i + 1] == 'b'):
			out.append(1)
			last = 'a'
		else:
			out.append(0)
	elif s[i] == 'a' and last == 'b':
		out.append(1)
	else:
		out.append(0)
print(*out)


from sys import stdin, stdout
from math import *
from string import *
from collections import deque

class calc:

	def __init__(self, value, pre):
		self.value = value
		self.pre = pre

class decision:

	def __init__(self, prefix=None, suffix=None):
		self.maxPrefix = prefix.copy() if prefix != None else None
		self.maxSuffix = suffix.copy() if suffix != None else None

	def setPrefix(self, value, pre):
		self.maxPrefix = calc(value, pre)

	def setSuffix(self, value, pre):
		self.maxSuffix = calc(value, pre)

def main():
	global n, s, res
	s = stdin.readline().replace('\n', '')
	n = len(s)
	res = [0] * n
	if s[0] == 'a':
		res[0] = 1
	for i in range(1, n):
		if s[i] == 'a':
			if s[i - 1] == 'a':
				res[i - 1] = 0
				res[i] = 1
			else:
				res[i - 1] = 1
				res[i] = 1
	stdout.write(' '.join([str(x) for x in res]))
	return 0
main()


s = input().strip()
n = len(s)
cond = s[0]
ans = []
for i in range(n - 1):
	if s[i + 1] == cond:
		ans.append('0')
	else:
		ans.append('1')
	cond = s[i + 1]
if cond == 'b':
	ans.append('0')
else:
	ans.append('1')
print(' '.join(ans))


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())

def check(l, n, k):
	for j in range(k):
		d = set()
		for i in range(j, n, k):
			d.add(l[i])
			if len(d) > 1:
				return 0
		if len(d) > 1:
			return 0
	return 1
t = 1
for _ in range(t):
	s = list(input())
	temp = ''
	n = len(s)
	an = [0] * n
	prev = 300
	for i in range(1, n):
		if s[i] == 'a':
			an[i - 1] ^= 1
			an[i] = 1
	print(*an)


s = input()
l = []
i = 0
while i < len(s):
	l.append(0)
	while i < len(s) and s[i] == 'b':
		l[-1] += 1
		i += 1
	l.append(0)
	while i < len(s) and s[i] == 'a':
		l[-1] += 1
		i += 1
i = 0
res = []
for (j, e) in enumerate(l):
	i += e
	if j % 2 == 0:
		if i != e and l[j + 1] > 0:
			if e:
				res.append(i - 1)
	elif e:
		res.append(i - 1)
v = ['0'] * len(s)
for e in res:
	v[e] = '1'
print(' '.join(v))


s = input()
ls = []
leftmost = s[0]
for i in range(0, len(s) - 1):
	rightmost = s[i]
	after = s[i + 1]
	if after != rightmost:
		ls.append(1)
		(leftmost, rightmost) = (rightmost, after)
	else:
		ls.append(0)
		rightmost = after
if leftmost == 'b':
	ls.append(1)
else:
	ls.append(0)
print(' '.join(map(str, ls)))


def main():
	s = list(input())
	n = len(s)
	res = [0] * n
	for i in range(1, n):
		if s[i] == 'a':
			res[i - 1] ^= 1
			res[i] = 1
	print(' '.join([str(c) for c in res]))
main()


s = input()
n = len(s)
ans = [False] * n
for i in range(1, n):
	if s[i] == 'a':
		ans[i - 1] = not ans[i - 1]
		ans[i] = True
print(*list(map(int, ans)))


def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))

def solve():
	S = input().strip()
	N = len(S)
	C = [False] * N
	for i in range(1, N):
		if S[i] == 'a':
			C[i - 1] = not C[i - 1]
			C[i] = True
		else:
			C[i] = False
	return ' '.join((str(int(c)) for c in C))
print(solve())


s = input()
n = len(s)
res = []
for i in range(1, n):
	if s[i] != s[i - 1]:
		res.append(1)
	else:
		res.append(0)
if s[n - 1] == 'a':
	res.append(1)
else:
	res.append(0)
for i in res:
	print(i, end=' ')


s = str(input())
n = len(s)
ansarr = [0] * len(s)
i = 0
first = 0
while i < n:
	if s[i] == 'b':
		while i < n and s[i] != 'a':
			i += 1
		if i == n:
			break
		elif first != 0:
			ansarr[i - 1] = 1
			first = 0
	else:
		while i < n and s[i] == 'a':
			ansarr[i] = 0
			i += 1
		first = 1
		ansarr[i - 1] = 1
print(*ansarr)


s = input().strip()
n = len(s)
ret = [0] * n
for i in range(1, n):
	if s[i] == 'a':
		ret[i] = 1
		ret[i - 1] ^= 1
print(*ret)


s = input()
n = len(s)
ans = [0] * n
for i in range(1, n):
	if s[i] == 'a':
		if ans[i - 1] == 0:
			ans[i - 1] = 1
		else:
			ans[i - 1] = 0
		ans[i] = 1
print(*ans)


s = input()
c = [0]
n = len(s)
for i in range(1, n - 1):
	if s[i + 1] == s[0]:
		c.append(1)
		s = s[:i + 1][::-1] + s[i + 1:]
	else:
		c.append(0)
if n == 1:
	print(0)
elif n == 2:
	if s == 'aa' or s == 'bb' or s == 'ab':
		print(0, 0)
	elif s == 'ba':
		print(0, 1)
else:
	if s[-1] == 'a':
		c.append(1)
	else:
		c.append(0)
	print(*c)


s = input()
n = len(s)
ans = []
s += 'b'
for i in range(n):
	if s[i] == 'b' and s[i + 1] == 'a' or (s[i] == 'a' and s[i + 1] == 'b'):
		ans.append(1)
	else:
		ans.append(0)
print(*ans)


def scand():
	return int(input())

def scana():
	return [int(x) for x in input().split()]
t = input()
ans = ['' for char in t]
n = len(t)
flag = 'a'
for i in range(n):
	if t[n - 1 - i] == flag:
		ans[n - 1 - i] = '1'
		flag = 'b' if flag == 'a' else 'a'
	else:
		ans[n - 1 - i] = '0'
print(' '.join(ans))


u = list(input())
n = len(u)
ans = [0] * n
for i in range(1, n):
	if u[i] != u[i - 1]:
		ans[i - 1] = 1
if u[-1] == 'a':
	ans[-1] = 1
print(' '.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
mod = 10 ** 9 + 7
pow2 = [1]

def main():
	s = input()
	a = []
	for i in s:
		if i == 'a' or i == 'b':
			a.append(i)
	ans = []
	for i in range(len(a)):
		f = 0
		if s[i] == 'a' and (i == len(a) - 1 or a[i + 1] == 'b'):
			f = 1
		elif s[i] == 'b' and (i < len(a) - 1 and a[i + 1] == 'a'):
			f = 1
		ans.append(f)
	print(*ans)
	return
main()


s = input()
s = s + 'b'
k = ''
i = 1
while i < len(s):
	if s[i - 1:i + 1] == 'ba' or s[i - 1:i + 1] == 'ab':
		k += ' 1'
	else:
		k += ' 0'
	i += 1
print(k[1:])


s = list(input())
n = len(s)
lis = [-1] * n
lis[0] = 0
for i in range(n - 1):
	if s[i] == s[i + 1]:
		lis[i] = 0
i = n - 1
while i >= 0 and s[i] != 'a':
	lis[i] = 0
	i -= 1
while i >= 0:
	if lis[i] == -1:
		lis[i] = 1
	i -= 1
print(*lis)


s = input().strip()
print(*(int(x != y) for (x, y) in zip(s, s[1:])), int(s[-1] == 'a'), end=' ')


def flip(wd):
	changes = []
	last = wd[0]
	for (i, x) in enumerate(wd):
		if x != last:
			changes.append(i - 1)
		last = x
	changes.append(len(wd) - 1)
	if wd[-1] == 'b':
		changes.pop(-1)
	res = [0] * len(wd)
	for ch in changes:
		res[ch] = 1
	return res

def test(wd):
	f = flip(wd)
	x = rev(wd, f)
	assert wd.count('a') == x.count('a')
	assert wd.count('b') == x.count('b')
	assert len(x) == len(wd)
	assert x == 'a' * wd.count('a') + 'b' * wd.count('b')
wd = input()
print(*flip(wd))


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def findSmallest(s):
	smallestChar = 999
	smallestIndex = len(s)
	for i in range(len(s) - 1, -1, -1):
		if ord(s[i]) < smallestChar:
			smallestChar = ord(s[i])
			smallestIndex = i
	return smallestIndex

def findLargest(s):
	largestChar = -1
	largestIndex = len(s)
	for i in range(len(s) - 1, -1, -1):
		if ord(s[i]) > largestChar:
			largestChar = ord(s[i])
			largestIndex = i
	return largestIndex
s = input().decode('utf-8').strip()
result = [0] * len(s)
smorla = True
smi = findSmallest(s)
while smi > 0:
	result[smi] = 1
	smorla = not smorla
	s = s[:smi]
	if smorla:
		smi = findSmallest(s)
	else:
		smi = findLargest(s)
print(' '.join([str(e) for e in result]))


t = input()
i = 0
res = [0 for _ in range(len(t))]
while i < len(t):
	if t[i] == 'a':
		j = i + 1
		while j < len(t) and t[j] == 'a':
			j += 1
		if i != 0:
			res[i - 1] = 1
		res[j - 1] = 1
		i = j
	else:
		i += 1
print(' '.join(map(str, res)))


def Main():
	arr = input()
	n = len(arr)
	res = {}
	res[0] = 0
	for i in range(1, n):
		if arr[i] == 'a':
			res[i - 1] ^= 1
			res[i] = 1
		else:
			res[i] = 0
	for x in res:
		print(res[x], end=' ')
Main()


s = list(input())
res = []
for i in range(len(s) - 1):
	if s[i] != s[i + 1]:
		res.append(1)
		s = s[:i + 1][::-1] + s[i + 1:]
	else:
		res.append(0)
print(*res, 0 if s < s[::-1] else 1)


s = [0 if x == 'a' else 1 for x in input().strip()]
ls = len(s)
sw = [0] * ls
for i in range(ls - 1):
	if s[i] != s[i + 1]:
		sw[i] = 1
		for j in range((i + 1) // 2):
			(s[j], s[i - j]) = (s[i - j], s[j])
if s[0] > s[ls - 1]:
	sw[ls - 1] = 1
print(*sw)


s = input()
n = len(s)
revs = [0] * n
c = 'a'
toc = {'a': 'b', 'b': 'a'}
for i in range(n - 1, -1, -1):
	if s[i] == c:
		c = toc[c]
		revs[i] = 1
print(' '.join(map(str, revs)))


a = input()
i = 1
n = len(a)
s = []
while i < n:
	if a[0] == 'a' and a[i] == 'a':
		search = 0
		a = a[:i][::-1] + a[i:]
		search = 0
		s.append(i)
	elif a[0] == 'b' and a[i] == 'b':
		search = 1
		a = a[:i][::-1] + a[i:]
		search = 1
		s.append(i)
	i += 1
b = [0] * n
for i in range(0, len(s)):
	b[s[i] - 1] = 1
cb = a.count('b')
ca = a.count('a')
if 'a' * ca + 'b' * cb != a:
	b[n - 1] = 1
print(*b)


import heapq, math
from collections import defaultdict, deque
import sys, os.path
if os.path.exists('C:/Users/Dhanush/Desktop/cp/input.txt'):
	sys.stdout = open('C:/Users/Dhanush/Desktop/cp/output.txt', 'w')
	sys.stdin = open('C:/Users/Dhanush/Desktop/cp/input.txt', 'r')
input = sys.stdin.readline

def reverse(end):
	start = 0
	while start < end:
		(l[start], l[end]) = (l[end], l[start])
		start += 1
		end -= 1
s = input().strip()
n = len(s)
ans = [0 for _ in range(n)]
l = list(s)
for i in range(1, n):
	if l[i] != l[i - 1]:
		ans[i - 1] = 1
		reverse(i - 1)
if l[0] == 'b':
	ans[n - 1] = 1
print(*ans)


a = list(input())
b = []
c = 0
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		b.append(i)
d = [0] * len(a)
for i in range(1, len(b)):
	d[b[i]] = 1
if a[-1] == 'a':
	d[-1] = 1
print(*d)


s = list(input())
ones = 0
for i in s:
	if i == 'a':
		ones += 1
	else:
		break
res = [0] * len(s)
for prefix in range(1, len(s) + 1):
	string = s[:prefix]
	one = 0
	for h in range(prefix - 1, -1, -1):
		if string[h] == 'a':
			one += 1
		else:
			break
	if ones < one:
		if prefix < len(s) and s[prefix] == 'a':
			continue
		ones = one
		s[:prefix] = s[:prefix][::-1]
		res[prefix - 1] = 1
	elif prefix < len(s):
		if s[0] == 'a' and s[prefix] == 'a':
			s[:prefix] = s[:prefix][::-1]
			res[prefix - 1] = 1
print(*res)


s = input()
out = [0] * len(s)
k2 = 0
if s[0] == 'a':
	for i in range(len(s) - 1):
		if s[i] == 'b' and s[i + 1] == 'a':
			(k1, k2) = (i, i)
			for j in range(k2 + 1, len(s)):
				if s[j] == 'b':
					break
				k2 += 1
			out[k1] = 1
			out[k2] = 1
			i = k2
else:
	f = 1
	for i in range(len(s) - 1):
		if f and s[i] == 'a' and (s[i + 1] == 'b'):
			out[i] = 1
			f = 0
		elif f == 0 and s[i] == 'b' and (s[i + 1] == 'a'):
			(k1, k2) = (i, i)
			for j in range(k2 + 1, len(s)):
				if s[j] == 'b':
					break
				k2 += 1
			out[k1] = 1
			out[k2] = 1
			i = k2
	if sum(out) == 0 and s[-1] == 'a':
		out[-1] = 1
print(' '.join(map(str, out)))


import math
import sys
DEBUG = False

def inp():
	return sys.stdin.readline().rstrip()

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def solve(S):
	N = len(S)
	a = S.count('a')
	b = N - a
	ans = []
	left = True
	for i in range(N - 1, -1, -1):
		c = S[i]
		if left:
			if c == 'a':
				ans.append(1)
				left = False
			else:
				ans.append(0)
		elif c == 'b':
			ans.append(1)
			left = True
		else:
			ans.append(0)
	ans.reverse()
	return ans

def main():
	S = inp()
	print(*solve(S))
main()


n = input()
x = [0] * len(n)
for i in range(len(n) - 1):
	if n[i] is n[i + 1]:
		continue
	else:
		x[i] = 1
if n[-1] is 'a':
	x[-1] = 1
for i in range(len(n)):
	print(x[i], end=' ')


s = input()
o = ''
for (i, c) in enumerate(s[:-1]):
	if c == 'b':
		if s[i + 1] == 'a':
			s = s[:i + 1][::-1] + s[i + 1:]
			o += '1'
		else:
			o += '0'
	elif s[i + 1] == 'b':
		o += '1'
		s = s[:i + 1][::-1] + s[i + 1:]
	else:
		o += '0'
if s[0] == 'b':
	s = s[::-1]
	o += '1'
else:
	o += '0'
print(' '.join(o))


import heapq
s = input()
n = len(s)
ans = []
std = sorted(s)
visq = []
stpt = 0
bpt = n - 1

def move_stpt(stpt):
	stpt += 1
	while stpt < n and visq and (std[stpt] == visq[0]):
		heapq.heappop(visq)
		stpt += 1
	return stpt
while bpt > 0:
	if s[bpt] == std[stpt]:
		ans.append(1)
		stpt = move_stpt(stpt)
		bpt -= 1
		while bpt > 0 and s[bpt] == std[stpt]:
			ans.append(0)
			stpt = move_stpt(stpt)
			bpt -= 1
		if bpt > 0 and s[bpt] != std[stpt]:
			heapq.heappush(visq, s[bpt])
			ans.append(1)
			bpt -= 1
	else:
		heapq.heappush(visq, s[bpt])
		ans.append(0)
		bpt -= 1
ans.append(0)
print(*reversed(ans))


a = list(map(str, input()))
l = len(a)
res = [0] * l
for i in range(1, l):
	if a[i] == a[0]:
		res[i - 1] = 1
		a[:i] = list(reversed(a[:i]))
if a[l - 1] == 'a' and a[0] != a[l - 1]:
	res[l - 1] = 1
for p in res:
	print(p, end=' ')


def not_last(c):
	if c == 'a':
		return 'b'
	return 'a'
s = input()
last = 'b'
res = []
for i in range(len(s) - 1):
	if s[i + 1] == last:
		res += [0]
	else:
		last = not_last(last)
		res += [1]
if last == 'a':
	res += [1]
else:
	res += [0]
print(' '.join(list(map(str, res))))


s = input()

def swap(i):
	return s[:i:-1] + s[i + 1:]
for e in range(len(s) - 1):
	if s[e] != s[e + 1]:
		print(1, end=' ')
	else:
		print(0, end=' ')
if s[-1] == 'a':
	print(1, end=' ')
else:
	print(0)


s = input()
n = len(s)
ans = []
bpt = n - 1
while bpt > 0:
	if s[bpt] == 'a':
		ans.append(1)
		bpt -= 1
		while bpt > 0 and s[bpt] == 'a':
			ans.append(0)
			bpt -= 1
		if bpt > 0 and s[bpt] != 'a':
			ans.append(1)
			bpt -= 1
	else:
		ans.append(0)
		bpt -= 1
ans.append(0)
print(*reversed(ans))


s = list(input())
for i in range(len(s) - 1):
	print(int(s[i] != s[i + 1]))
	if s[i] != s[i + 1]:
		s[:i + 1] = s[i::-1]
print(int(s[-1] == 'a'))


def ans(s):
	flag = True
	for i in s:
		if i == 'b':
			flag = False
	if flag:
		return [0 for i in s]
	h = []
	for i in range(len(s)):
		j = len(s) - 1 - i
		if s[j] == 'a':
			if j == 0:
				return [0 for i in s]
			f = ans(s[j - 1::-1])
			return f[::-1] + [1] + h
		h.append(0)
	return [0 for i in s]

def main():
	s = input()
	h = [0 for c in s]
	start = True
	last = s[0] == 'a'
	for i in range(len(s)):
		if s[i] == 'a':
			if start:
				continue
			if not last:
				h[i - 1] = 1
			last = True
		else:
			start = False
			if last:
				h[i - 1] = 1
			last = False
	if s[-1] == 'a':
		h[-1] = 1
	print(' '.join([str(x) for x in h]))
main()


s = input()
ans = []
for i in range(len(s) - 1):
	if s[i] != s[i + 1]:
		ans.append(i)
ans.append(len(s) - 1)
if s[-1] == 'b':
	ans = ans[:len(ans) - 1]
an = [0] * len(s)
for i in ans:
	an[i] = 1
print(*an, sep=' ')


from sys import stdin, stdout
a = list(input())
b = sorted(a)
l = len(a)
ans = ['0' for i in range(l)]
for i in range(1, l):
	if a == b:
		break
	if a[0] == 'a':
		if a[i] == 'a':
			a[0:i - 1] = a[i - 1:0:-1]
			ans[i - 1] = '1'
	elif a[i] == 'b':
		a[0:i - 1] = a[i - 1:0:-1]
		ans[i - 1] = '1'
if a[0] == 'b':
	ans[l - 1] = '1'
stdout.write(' '.join(ans))


def solve(s):
	res = [0 for _ in range(len(s))]
	for i in range(1, len(s)):
		if s[i] == 'a':
			res[i] = 1
			res[i - 1] = 1 - res[i - 1]
	return res
lst = list(input())
print(' '.join(list(map(str, solve(lst)))))


l = input()
n = len(l)
k = [0 for i in range(n)]
for t in range(1, n):
	if l[t] != l[t - 1]:
		k[t - 1] = 1
if l[-1] == 'b':
	k[-1] = 0
else:
	k[-1] = 1
print(*k)


a = input()
ans = [0]
for i in range(1, len(a)):
	if a[i] == 'a':
		ans[-1] ^= 1
		ans.append(1)
	else:
		ans.append(0)
print(*ans)


s = input()
idx = []
n = len(s)
if n == 1:
	print(0)
else:
	for i in range(1, n):
		if s[i] != s[i - 1]:
			idx.append(i - 1)
	idx.append(n - 1)
	res = [0] * n
	if s[-1] == 'b':
		for i in range(1, len(idx) - 1):
			res[idx[i]] = 1
	else:
		for i in range(1, len(idx)):
			res[idx[i]] = 1
	print(' '.join(map(str, res)))


s = input()
c = 'ab'
j = 0
i = len(s)
r = [0] * i
try:
	while 1:
		i = s.rindex(c[j], 0, i)
		r[i] = 1
		j ^= 1
except:
	print(*r)


from sys import stdin, stdout

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
s = input()
ans = [0] * 1007
for i in range(1, len(s)):
	if s[i] == 'a':
		ans[i - 1] ^= 1
		ans[i] = 1
print(*ans[:len(s)])


string = input()
sortedS = list(string)
sortedS.sort()
n = len(string)
start = 0
end = n - 1
order = False
i = n - 1
swap = ['0'] * n
while i >= 0:
	if order:
		if sortedS[start] != string[i]:
			swap[i] = '1'
			order = not order
		start += 1
	else:
		if sortedS[end] != string[i]:
			swap[i] = '1'
			order = not order
		end -= 1
	i -= 1
print(' '.join(swap))


def solve(word):
	swaps = [False] * len(word)
	modified = word
	for i in range(1, len(word)):
		if word[i] != word[i - 1]:
			swaps[i - 1] = True
			modified = modified[i - 1::-1] + modified[i:]
	if modified[0] != 'a':
		swaps[-1] = True
		modified = modified[::-1]
	return (swaps, modified)
word = input()
(swaps, _) = solve(word)
print(' '.join(['1' if x else '0' for x in swaps]))


s = list(input())
n = len(s)
arr = [0] * n
i = 1
while i < n:
	if s[i] == 'b':
		arr[i - 1] = 1
	while s[i] == 'b':
		i += 1
		if i == n:
			break
	if i != n and s[i - 1] == 'b':
		arr[i - 1] = 1
	i += 1
if s[n - 1] != 'b':
	arr[-1] = 1
print(' '.join(map(str, arr)))


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	c = dict(Counter(l))
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	s = list(si())
	ans = [0] * len(s)
	prev = s[0]
	for i in range(1, len(s)):
		if s[i] == 'a':
			ans[i - 1] = abs(1 - ans[i - 1])
			ans[i] = abs(1 - ans[i])
			prev = s[i - 1]
		else:
			prev = s[i]
	print(*ans)
t = 1
for _ in range(t):
	solve()


def main():
	l = list(input())
	wyn = [0] * len(l)
	pos = 0
	for i in range(1, len(l)):
		if l[i] == 'a':
			wyn[i - 1] ^= 1
			wyn[i] ^= 1
	print(*wyn, sep=' ')
main()


def reverse(s, index):
	s1 = s[:index + 1]
	s1 = s1[::-1]
	s1 = s1 + s[index + 1:]
	return s1

def main():
	s = input()
	n = len(s)
	ans = []
	for i in range(len(s) - 1):
		if s[i] != s[i + 1]:
			s = reverse(s, i)
			ans.append(1)
		else:
			ans.append(0)
	if s[-1] == 'a':
		s = reverse(s, n - 1)
		ans.append(1)
	else:
		ans.append(0)
	for i in ans:
		print(i, end=' ')
main()


s = [0 if x == 'a' else 1 for x in input().strip()]
ls = len(s)
sw = [0] * ls
fe = le = s[0]
for i in range(1, ls, 1):
	if s[i] != le:
		sw[i - 1] = 1
		fe = le
		le = s[i]
if fe > s[ls - 1]:
	sw[ls - 1] = 1
print(*sw)


gi = lambda : list(map(int, input().split()))
s = input()
n = len(s)
ans = [0 for e in range(n)]
k = 1
while k < n:
	if s[k] == 'a':
		temp = k
		while k < n and s[k] == 'a':
			k += 1
		ans[temp - 1] = ans[k - 1] = 1
	k += 1
print(*ans)


import sys
input = lambda : sys.stdin.readline().rstrip()
s = [*input()]
ans = [0] * len(s)
for i in range(1, len(s)):
	if s[i] == 'a':
		ans[i - 1] ^= 1
		ans[i] = 1
print(*ans)


gcd = lambda a, b: gcd(b, a % b) if b else a

def main():
	arr = input()
	sa = 0
	for i in arr:
		if i == 'a':
			sa += 1
	brr = [0 for i in range(len(arr))]
	for i in range(len(arr) - 1):
		if arr[i] != arr[i + 1]:
			arr = arr[:i + 1][::-1] + arr[i + 1:]
			brr[i] = 1
	if arr[-1] == 'a':
		brr[-1] = 1
	print(*brr)
main()


s = input()
ss = sorted(s)
r = [0] * len(s)
b_char = 'b'
for (i, c) in enumerate(reversed(s)):
	if c != b_char:
		r[len(s) - i - 1] = 1
		b_char = 'a' if b_char == 'b' else 'b'
print(' '.join([str(i) for i in r]))


s = list(input())
n = len(s)
R = [0] * n
for i in range(n - 1):
	if s[i] == 'b':
		if s[i + 1] == 'a':
			R[i] = 1
		else:
			pass
	elif s[i + 1] == 'a':
		pass
	else:
		R[i] = 1
if s[n - 1] == 'a':
	R[n - 1] = 1
print(*R)


inputs = [s for s in input()]
array_a = []
result = [0] * len(inputs)
for i in range(len(inputs)):
	if inputs[i] == 'a':
		array_a.append(i)
if len(array_a) == 0:
	pass
else:
	i = 0
	while i < len(array_a):
		counter = 1
		while i + 1 < len(array_a) and array_a[i] + 1 == array_a[i + 1]:
			counter += 1
			i += 1
		if array_a[i] - counter >= 0:
			result[array_a[i] - counter] = 1
		result[array_a[i]] = 1
		i += 1
print(' '.join([str(s) for s in result]))


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
S = list(input())
N = len(S)
ans = [0] * N
for i in range(N - 1):
	if S[i] != S[i + 1]:
		S[:i + 1] = S[:i + 1][::-1]
		ans[i] = 1
if S[-1] == 'a':
	ans[-1] = 1
print(' '.join(map(str, ans)))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
a = list(input())
n = len(a)
ans = [0] * n
for i in range(1, n):
	if a[i] == 'a':
		ans[i - 1] ^= 1
		ans[i] = 1
print(*ans)


def min_word(s):
	(n, flag) = (len(s), 0)
	result = [0] * n
	for i in range(n - 1, -1, -1):
		if s[i] == 'a':
			result[i] = 1 - flag
			flag = 1
		else:
			result[i] = flag
			flag = 0
	return result
print(*min_word(input()))


def rev(s, n):
	x = s[0:n][::-1]
	return str(x + s[n:])
s = input()
n = len(s)
ans = ''
for i in range(n - 1):
	if s[i] == 'a' and s[i + 1] == 'b':
		s = rev(s, i + 1)
		ans += '1 '
	elif s[i] == 'b' and s[i + 1] == 'a':
		s = rev(s, i + 1)
		ans += '1 '
	else:
		ans += '0 '
if s[n - 1] == 'a':
	ans += '1'
else:
	ans += '0'
print(ans)


s = input()
n = len(s)
l = [0 for i in range(n)]
a = 'a'
b = 'b'
c = a
for i in range(n - 1, -1, -1):
	if c == s[i]:
		l[i] = 1
		if c == a:
			c = b
		else:
			c = a
for i in l:
	print(i, end=' ')


def main():
	s = input()
	aFront = 1
	ans = []
	for i in range(1, len(s) + 1):
		needAFront = 1
		if i < len(s) and s[i] == 'a':
			needAFront = 0
		if aFront != needAFront:
			ans.append(1)
		else:
			ans.append(0)
		aFront = needAFront
	print(*ans)
	return
main()


s = input()
t = s[0]
for i in range(1, len(s)):
	if s[i] == t:
		t = s[i - 1]
		print('1 ', end='')
	else:
		print('0 ', end='')
if t == 'b':
	print(1)
else:
	print(0)


s = input()
i = 0
result = []
n = len(s)
i = 0
j = 0
while i < n and j < n:
	if s[i] == 'a':
		j = i + 1
		while j < n and s[j] == 'a':
			j += 1
		if i - 1 >= 0:
			result.append(i - 1)
		result.append(j - 1)
		i = j + 1
	else:
		i += 1
for i in range(n):
	if i in result:
		print(1, end=' ')
	else:
		print(0, end=' ')


s = input()
n = len(s)
ans = []
for i in range(n - 1):
	if s[i] != s[i + 1]:
		ans.append(1)
	else:
		ans.append(0)
if s[-1] == 'a':
	ans.append(1)
else:
	ans.append(0)
for t in ans:
	print(t, end=' ')


a = input()
(res, string, n) = ([], '', len(a))
for (i, x) in enumerate(a):
	string += x
	s = string[::-1]
	if i < n - 1:
		if a[i + 1] == string[0]:
			string = s
			res.append(1)
			continue
	elif s < string:
		string = s
		res.append(1)
		continue
	res.append(0)
print(*res)


s = input()
ans = [0]
for i in range(1, len(s)):
	if s[i] == 'a':
		ans[-1] = 1 - ans[-1]
		ans.append(1)
	else:
		ans.append(0)
print(' '.join([str(i) for i in ans]))


def g_couple(itr):
	a = next(itr)
	for b in itr:
		yield (a, b)
		a = b

def g_input(str):
	nb = 0
	for c in str:
		if c != ' ':
			nb = nb * 10 + int(c)
		else:
			yield nb
			nb = 0
	yield nb

def main():
	l_char = list(input())
	l_char.reverse()
	l_bits = [int(char == 'b') for char in l_char]
	l_switch = []
	switch_bit = 0
	for bit in l_bits:
		if bit == switch_bit:
			switch_bit = (switch_bit + 1) % 2
			l_switch.append(1)
		else:
			l_switch.append(0)
	l_switch.reverse()
	l_switch = [str(e) for e in l_switch]
	print(' '.join(l_switch))
main()


s = input()
ANS = []
s = s + 'b'
now = s[0]
if now == 'a':
	i = s.index('b')
elif 'a' in s:
	i = s.index('a')
else:
	i = 0
while i < len(s) - 1:
	if s[i] == 'a' and s[i + 1] == 'b':
		ANS.append(i)
	elif s[i] == 'b' and s[i + 1] == 'a':
		ANS.append(i)
	i += 1
LIST = [0 for i in range(len(s) - 1)]
for a in ANS:
	LIST[a] = 1
for l in LIST:
	print(l, end=' ')


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def solve():
	a = list(inp())
	n = len(a)
	ans = [0] * n
	if a.count('a') == 0:
		printlist(ans)
		nextline()
	elif a.count('a') == 1:
		ans[a.index('a')] = 1
		printlist(ans)
		nextline()
	else:
		st = a.index('a')
		chck = a[st]
		for i in range(st + 1, n):
			if a[i] == chck:
				continue
			else:
				ans[i - 1] = 1
				chck = a[i]
		if a[n - 1] == 'a':
			ans[n - 1] = 1
		printlist(ans)
		nextline()
testcase(1)


s = list(input())
a = [0 for i in range(len(s))]
for i in range(1, len(s)):
	if s[i] == 'a':
		a[i] = 1
		a[i - 1] ^= 1
print(' '.join(list(map(str, a))))


s = input()
print(*(int(x != y) for (x, y) in zip(s, s[1:] + 'b')))


s = input() + 'b'
for i in range(len(s) - 1):
	if s[i] == 'a' and s[i + 1] == 'b' or (s[i] == 'b' and s[i + 1] == 'a'):
		print(1, end=' ')
	else:
		print(0, end=' ')


import sys
from collections import deque
input = sys.stdin.readline
s = list(input().strip())
groups = set()
target = s[0]
for i in range(len(s)):
	if s[i] != target:
		groups.add(i - 1)
		target = s[i]
if s[-1] != 'b':
	groups.add(len(s) - 1)
ans = ''
for i in range(len(s)):
	if i in groups:
		ans += '1 '
	else:
		ans += '0 '
print(ans)


s = input()
result = [0 for i in range(len(s))]
pWa = 0
for i in reversed(range(len(s))):
	if s[i] == 'a':
		if not pWa:
			result[i] = 1
		if i - 1 >= 0 and s[i - 1] == 'b':
			result[i - 1] = 1
		pWa = 1
	else:
		pWa = 0
print(*result)


s = input()
ans = [0 for i in range(len(s))]
for i in range(1, len(s)):
	if s[i] == 'a' and s[i - 1] == 'b' or (s[i] == 'b' and s[i - 1] == 'a'):
		ans[i - 1] = 1
		s = s[0:i][::-1] + s[i:]
if s[-1] == 'a':
	ans[-1] = 1
print(*ans)


from collections import defaultdict, Counter
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))
ans_ = []

def solve():
	s = st()
	n = len(s)
	ans = [0] * n
	f = [0, 1][s[0] == 'a']
	ind = 0
	if s[-1] == 'a':
		s += 'b'
	while True:
		if f == 0:
			ind = s.find('ab', ind)
			if -1 == ind:
				break
			ans[ind] = 1
			f = 1
		else:
			ind = s.find('ba', ind)
			if -1 == ind:
				break
			ans[ind] = 1
			f = 0
	ans_.append(ans)
solve()
for i in ans_:
	print(*i)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if test:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
test = False

def cmp(l1, l2):
	if len(l1) != len(l2):
		print('lenght mismatch', l1, l2)
	for i in range(len(l1)):
		if l1[i] != l2[i]:
			return False
	return True

def main():
	s = list(input())
	res = [0]
	for i in range(1, len(s)):
		we = s[:i]
		if s[i] <= we[0]:
			res[-1] = 0 if res[-1] == 1 else 1
			res.append(1)
			s = [s[i]] + we + s[i + 1:] if i + 1 < len(s) else [s[i]] + we
		else:
			res.append(0)
	display_list(res)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if test else main()
else:
	cProfile.run('main()') if test else main()


from sys import stdin, stdout
from math import sqrt
import math
import heapq
from itertools import accumulate
s = input()
N = len(s)
for i in range(N):
	if i != N - 1:
		if s[i] == 'b' and s[i + 1] == 'a':
			print(1, end=' ')
		elif s[i] == 'a' and s[i + 1] == 'b':
			print(1, end=' ')
		else:
			print(0, end=' ')
	elif i == N - 1:
		if s[i] == 'a':
			print(1, end=' ')
		else:
			print(0, end=' ')


s = input() + 'b'
a = list(s)
x = [0]
for i in range(1, len(a) - 1):
	if a[i] != a[i + 1] and a[i + 1] == a[0]:
		h = a[:i + 1]
		k = list(reversed(h))
		a = k + a[i + 1:]
		x.append(1)
	else:
		x.append(0)
print(*x)


a = input()
print(*(int(x != y) for (x, y) in zip(a, a[1:] + 'b')))


seq = input()
result = []
len_ = len(seq)
result.append('0')
if len_ > 1:
	for i in range(1, len_ - 1):
		if seq[i] == 'b' and seq[i + 1] == 'a':
			result.append('1')
		elif seq[i] == 'a' and seq[i + 1] == 'b':
			result.append('1')
		else:
			result.append('0')
	if seq[-1] == 'a':
		result.append('1')
	else:
		result.append('0')
print(' '.join(result))


s = input()
l = [[0 for i in range(len(s))] for j in range(2)]
for i in range(len(s)):
	if s[i] == 'b':
		l[0][i] = 0
		l[1][i] = 1
	else:
		l[0][i] = 1
		l[1][i] = 0
ans = []
w = 0
for i in range(len(s) - 1, -1, -1):
	ans.append(l[w][i])
	w = abs(w - l[w][i])
ans = ans[::-1]
print(*ans)


from itertools import groupby
s = '#' + input()
l = len(s)
ss = s[1:]
ans1 = [0] * (l - 1)
gb = [list(g) for (k, g) in groupby(ss)]
(ll, first_a, turn_a) = (0, False, False)
for i in gb:
	if i[0] == 'a':
		if not first_a:
			ll += len(i)
			ans1[ll - 1] = 1
			first_a = True
			turn_a = True
		else:
			ll += len(i)
			ans1[ll - 1] = 1
			turn_a = True
	else:
		ll += len(i)
		ans1[ll - 1] = 1
		turn_a = False
if not turn_a:
	ans1[ll - 1] = 0
print(*ans1)


from bisect import bisect_left
import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math
import heapq

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	s = sin()
	n = len(s)
	l = [0] * n
	i = 1
	while i < n:
		x = s[:i]
		p1 = x + s[i]
		p2 = x[::-1] + s[i]
		if p2[::-1] < p1:
			l[i - 1] = 1 - l[i - 1]
			l[i] = 1
			s = p2[::-1] + s[i + 1:]
		i += 1
	print(*l)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


s = input()
c = 0
for i in range(len(s)):
	if s[i] == 'a' and c == 0:
		c = 1
		if i != len(s) - 1:
			if s[i + 1] == 'a':
				print(0, end=' ')
			else:
				print(1, end=' ')
		else:
			print(1, end=' ')
	elif s[i] == 'b' and c == 0:
		print(0, end=' ')
	elif s[i] == 'a' and i != len(s) - 1:
		if s[i + 1] == 'a':
			print(0, end=' ')
		else:
			print(1, end=' ')
	elif s[i] == 'b' and i != len(s) - 1:
		if s[i + 1] == 'a':
			print(1, end=' ')
		else:
			print(0, end=' ')
	elif s[i] == 'b' and i == len(s) - 1:
		print(0, end=' ')
	elif s[i] == 'a' and i == len(s) - 1:
		print(1, end=' ')


s = input()
r = []
for i in s:
	if i == 'a':
		if len(r) != 0:
			r[-1] = 1 - r[-1]
		r.append(1)
	else:
		r.append(0)
print(' '.join(map(str, r)))


a = list(input())
flag = a[0] == 'a'
for i in range(len(a) - 1):
	if a[i] != a[i + 1]:
		print(1)
		a[:i + 1] = a[i::-1]
		flag = a[0] == 'a'
	else:
		print(0)
if a[0] == 'a':
	print(0)
else:
	print(1)
	a[:] = a[::-1]


s = input()
output = []
best = s[0]
rev = False
s2 = s[1:]
for i in s2:
	if i <= best:
		output.append(rev)
		rev = True
		best = i
	else:
		output.append(not rev)
		rev = False
output.append(not rev)
for i in output:
	if i:
		print(0, end=' ')
	else:
		print(1, end=' ')


def main():
	s = list(input().strip())
	i = -1
	n = len(s)
	b = [0] * n
	for j in range(n):
		if s[j] == 'a':
			if i != -1:
				b[i] ^= 1
				b[j - 1] ^= 1
			i = j
	if i != -1:
		b[i] = 1
	for x in b:
		print(x, end=' ')
	print()
main()


base = input()
pseq = []
beg = 0
c = base[0]
rots = []
for i in range(1, len(base)):
	if base[i - 1] == 'b' and base[i] == 'a':
		base = base[i - 1::-1] + base[i:]
		rots.append(i - 1)
	elif base[i - 1] == 'a' and base[i] == 'b':
		base = base[i - 1::-1] + base[i:]
		rots.append(i - 1)
if base[-1] == 'a':
	rots.append(len(base) - 1)
	base = base[::-1]
i = 0
out = []
for k in range(len(base)):
	if i < len(rots) and k == rots[i]:
		i += 1
		out.append('1')
	else:
		out.append('0')
print(' '.join(out))


from sys import stdin, setrecursionlimit
from itertools import combinations
setrecursionlimit(200000)

def reverse_check_big(string, index):
	temp = string[:index + 1]
	forward = ''.join(temp)
	reverse = ''.join(temp[::-1])
	if reverse > forward:
		return True
	else:
		return False

def change(string, index):
	temp = string[:index + 1]
	temp = temp[::-1]
	for i in range(index + 1):
		string[i] = temp[i]

def reverse_check_small(string, index):
	temp = string[:index + 1]
	forward = ''.join(temp)
	reverse = ''.join(temp[::-1])
	if reverse < forward:
		return True
	else:
		return False

def find_smaller_index(string, index):
	malph = 'z'
	ans = -1
	for i in range(index + 1):
		if string[i] <= malph:
			malph = string[i]
			ans = i
	return ans

def find_bigger_index(string, index):
	malph = 'a'
	ans = -1
	for i in range(index + 1):
		if string[i] >= malph:
			malph = string[i]
			ans = i
	return ans
string = list(stdin.readline().strip())
binary = [0] * len(string)
flag = 0
index = len(string) - 1
process = []
while index >= 0:
	if flag == 0:
		new_index = find_smaller_index(string, index)
		if new_index > 0:
			process.append([new_index - 1, 1])
			flag = 1
		index = new_index - 1
	else:
		new_index = find_bigger_index(string, index)
		if new_index > 0:
			process.append([new_index - 1, 0])
			flag = 0
		index = new_index - 1
index = -1
for i in range(len(string)):
	if len(process) == 0:
		break
	elif i > index:
		(index, t) = process.pop()
	if t == 0:
		if string[i] > string[0]:
			pass
		elif string[i] == string[0]:
			if reverse_check_small(string, i):
				change(string, i)
				binary[i] = 1
			else:
				pass
		else:
			change(string, i)
			binary[i] = 1
	elif string[i] < string[0]:
		pass
	elif string[i] == string[0]:
		if reverse_check_big(string, i):
			change(string, i)
			binary[i] = 1
		else:
			pass
	else:
		change(string, i)
		binary[i] = 1
index = find_smaller_index(string, len(string) - 1)
change(string, index)
binary[index] = 1
print(*binary)


s = input()
arr_ans = [0] * len(s)
for i in range(1, len(s)):
	if s[i] == 'a':
		arr_ans[i - 1] = (arr_ans[i - 1] + 1) % 2
		arr_ans[i] += 1
print(*arr_ans)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	s = input()
	n = len(s)
	change = [0 for x in range(n)]
	cnt = 0
	ans = 0
	prevtorev = 0
	prev = 0
	for x in range(n):
		if s[x] == 'a':
			change[prev] = 1
			cnt += 1
			prevtorev = x
		else:
			change[prevtorev] = 1
			prev = x
			cnt = 0
	change[prevtorev] = 1
	print(*change)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
import sys
input = sys.stdin.readline
from collections import Counter, defaultdict, deque

def f(s):
	n = len(s)
	ans = [0 for i in range(n)]
	aflag = False
	for i in range(n):
		if i > 0 and s[i - 1] == 'a' and (s[i] == 'b'):
			ans[i - 1] = 1
		if i < n - 1 and s[i] == 'b' and (s[i + 1] == 'a') and aflag:
			ans[i] = 1
		if s[i] == 'a':
			aflag = True
	if s[-1] == 'a':
		ans[-1] = 1
	return ans
t = 1
result = []
for i in range(t):
	s = input().strip()
	result.append(f(s))
for i in range(t):
	for j in range(len(result[i])):
		print(result[i][j], end=' ')
	print()


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(i) for i in st()]
lasta = -1
s = st()
n = len(s)
for i in range(n):
	if s[i] == 'a':
		lasta = i
ans = [0] * n
ans[lasta] = 1
for i in range(lasta):
	if i == n - 1 or s[i] != s[i + 1]:
		ans[i] = 1
print(*ans)


s = input()
n = len(s)
dp = []
dp.append([])
dp.append([])
dp[0].append((s[0], [0]))
dp[1].append((s[0], [0]))
for i in range(1, len(s)):
	(t0, sw0) = dp[0][i - 1]
	(t1, sw1) = dp[1][i - 1]
	g = (t1 + s[i])[::-1]
	if t0 + s[i] > g:
		sw = sw1.copy()
		sw.append(1)
		dp[0].append((g, sw))
	else:
		sw = sw0.copy()
		sw.append(0)
		dp[0].append((t0 + s[i], sw))
	g = (t0 + s[i])[::-1]
	if t1 + s[i] < g:
		sw = sw0.copy()
		sw.append(1)
		dp[1].append((g, sw))
	else:
		sw = sw1.copy()
		sw.append(0)
		dp[1].append((t1 + s[i], sw))
print(*dp[0][n - 1][1])


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
S = input()
zs = list(S)
zs.sort()
N = len(S)
res = [0 for i in range(N)]
for i in range(N - 1, -1, -1):
	if S[i] == zs[-1]:
		res[i] = 0
		zs = zs[:i]
		continue
	zs = list(reversed(zs))
	zs = zs[:i]
	res[i] = 1
for x in res:
	print(x, end=' ')


s = input().strip()
n = len(s)
b = (s[:1], [0])
w = (s[:1], [0])
for i in range(1, n):
	b0 = b[0] + s[i]
	b1 = s[i] + w[0][::-1]
	w0 = w[0] + s[i]
	w1 = s[i] + b[0][::-1]
	bcopy = b
	if b0 < b1:
		b = (b0, b[1] + [0])
	else:
		b = (b1, w[1] + [1])
	if w0 > w1:
		w = (w0, w[1] + [0])
	else:
		w = (w1, bcopy[1] + [1])
print(*b[1])


from math import inf as inf
from math import *
from collections import *
import sys
input = sys.stdin.readline
t = 1
while t:
	t -= 1
	a = input().rstrip('\n')
	b = a[:]
	for i in range(len(a) - 1):
		if a[i] == a[i + 1]:
			print(0, end=' ')
		else:
			print(1, end=' ')
	if a[-1] == 'a':
		print(1, end=' ')
	else:
		print(0, end=' ')