An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $091$), a colon (ASCII code $058$), some (possibly zero) vertical line characters (ASCII code $124$), another colon, and a closing bracket (ASCII code $093$). The length of the accordion is the number of characters in it.

For example, [::], [:||:] and [:|||:] are accordions having length $4$, $6$ and $7$. (:|:), {:||:}, [:], ]:||:[ are not accordions. 

You are given a string $s$. You want to transform it into an accordion by removing some (possibly zero) characters from it. Note that you may not insert new characters or reorder existing ones. Is it possible to obtain an accordion by removing characters from $s$, and if so, what is the maximum possible length of the result?


-----Input-----

The only line contains one string $s$ ($1 \le |s| \le 500000$). It consists of lowercase Latin letters and characters [, ], : and |.


-----Output-----

If it is not possible to obtain an accordion by removing some characters from $s$, print $-1$. Otherwise print maximum possible length of the resulting accordion.


-----Examples-----
Input
|[a:b:|]

Output
4

Input
|]:[|:]

Output
-1

Difficulty: EASY

Solutions:
s = input()
n = len(s)
p1 = s.find('[')
p2 = s.find(':', p1)
p4 = s.rfind(']')
p3 = s.rfind(':', p2, p4)
if p1 < p2 and p2 < p3 and (p3 < p4):
	k = s[p2 + 1:p3].count('|')
	print(k + 4)
else:
	print(-1)


s = input()
if '[' in s:
	s = s[s.find('[') + 1:]
	if ']' in s:
		s = s[:s.rfind(']')]
		if s.count(':') >= 2:
			s = s[s.find(':') + 1:s.rfind(':')]
			print(s.count('|') + 4)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


s = str(input().strip())
i = 0
n = len(s)
while i < n and s[i] != '[':
	i += 1
if i == n:
	print(-1)
	return
j = n - 1
while j > i and s[j] != ']':
	j -= 1
if j <= i:
	print(-1)
	return
while i < j and s[i] != ':':
	i += 1
if i == j:
	print(-1)
	return
while j > i and s[j] != ':':
	j -= 1
if j == i:
	print(-1)
	return
k = i + 1
c = 0
while k < j:
	if s[k] == '|':
		c += 1
	k += 1
print(c + 4)


from sys import stdin

def get_freq(string):
	opening = [0, -1]
	closing = [0, -1]
	colon = 0
	for i in range(len(string)):
		if string[i] == '[':
			opening[0] += 1
			if opening[1] == -1:
				opening[1] = i
				continue
		elif string[i] == ']':
			closing[0] += 1
			closing[1] = max(closing[1], i)
		elif string[i] == ':':
			colon += 1
	return (opening, closing, colon)
string = list(stdin.readline().strip())
(opening, closing, colon) = get_freq(string)
if opening[0] > 0 and closing[0] > 0 and (colon >= 2):
	if opening[1] < closing[1]:
		colon_count = [0, -1, -1]
		for i in range(opening[1] + 1, closing[1]):
			if string[i] == ':':
				colon_count[0] += 1
				if colon_count[1] == -1:
					colon_count[1] = i
				colon_count[2] = max(colon_count[2], i)
		if colon_count[0] >= 2:
			chars = 0
			for i in range(colon_count[1], colon_count[2] + 1):
				if string[i] == '|':
					chars += 1
			print(4 + chars)
			exit()
		else:
			print(-1)
			exit()
	else:
		print(-1)
		exit()
else:
	print(-1)
	exit()


s = input()
try:
	st = s.find('[')
	en = s.rfind(']')
	b = s[st:en + 1]
	st1 = b.find(':')
	en1 = b.rfind(':')
	c = b[st1:en1 + 1]
	if st1 == en1:
		print(-1)
	else:
		print(4 + c.count('|'))
except:
	print(-1)


def abc(s, low, high):
	if high < low:
		return -1
	s = s[low:high + 1]
	a = -1
	for i in s:
		a += 1
		if i == ':':
			break
	l = len(s)
	b = l
	for i in range(l - 1, -1, -1):
		b -= 1
		if s[i] == ':':
			break
	if a >= b:
		return -1
	s = s[a:b + 1]
	ct = 0
	for i in s:
		if i == '|':
			ct += 1
	return ct + 4
s = input()
l = len(s)
low = -1
high = len(s)
for i in s:
	low += 1
	if i == '[':
		break
for i in range(l - 1, -1, -1):
	high -= 1
	if s[i] == ']':
		break
print(abc(s, low, high))


import sys
s = input()
bra_l = s.find('[')
bra_r = s.rfind(']')
if bra_l >= 0 and bra_r > bra_l:
	s = s[bra_l:bra_r + 1]
	ans = len(s)
	col_l = s.find(':')
	col_r = s.rfind(':')
	if col_l >= 0 and col_r > col_l:
		ans -= col_l - 1
		ans -= len(s) - 2 - col_r
		for i in range(col_l + 1, col_r):
			if s[i] != '|':
				ans -= 1
		print(ans)
	else:
		print(-1)
else:
	print(-1)


s = list(input())
f1 = True
f2 = f3 = f4 = f5 = False
a = []
for x in s:
	if x == ']' and f4:
		a.append(x)
		f5 = True
	if x == ':' and f3:
		a.append(x)
		f4 = True
	if x == '|' and f3:
		a.append(x)
	if x == ':' and f2:
		a.append(x)
		f2 = False
		f3 = True
	if x == '[' and f1:
		a.append(x)
		f1 = False
		f2 = True
if f5:
	f6 = True
	f7 = False
	for x in reversed(a):
		if f7:
			if x == ':':
				f7 = False
			a.pop()
		if f6:
			if x == ']':
				f6 = False
				f7 = True
			a.pop()
	c = 4
	for x in a:
		if x == '|':
			c += 1
	print(c)
else:
	print(-1)


s = input()
pos1 = -1
pos2 = -1
pos3 = -1
pos4 = -1
for i in range(0, len(s)):
	if s[i] == '[':
		pos1 = i
		break
for i in range(len(s) - 1, pos1, -1):
	if s[i] == ']':
		pos2 = i
		break
for i in range(pos1, pos2 + 1):
	if s[i] == ':':
		pos3 = i
		break
for i in range(pos2, pos3, -1):
	if s[i] == ':':
		pos4 = i
		break
if pos1 == -1 or pos2 == -1 or pos3 == -1 or (pos4 == -1) or (len(s) < 4):
	print('-1')
else:
	c = 0
	for j in range(pos3, pos4):
		if s[j] == '|':
			c = c + 1
	print(c + 4)


s = input()
y = []
for i in s:
	y.append(i)
i = f = 0
while i < len(y):
	if y[i] == '[':
		q = i
		f = 1
	if y[i] == ':' and f == 1:
		q1 = i
		f = 2
		break
	i = i + 1
if f != 2:
	print(-1)
else:
	j = len(y) - 1
	while j >= 0:
		if y[j] == ']':
			f = 3
			q2 = j
		if y[j] == ':' and f == 3:
			if q1 < j:
				f = 4
				q3 = j
			break
		j = j - 1
	if f != 4:
		print(-1)
	else:
		count = 0
		q1 = q1 + 1
		while q1 < q3:
			if y[q1] == '|':
				count = count + 1
			q1 = q1 + 1
		print(count + 4)


def main():
	s = input()
	pos = s.find('[')
	if pos == -1:
		print(-1)
		return
	l = s.find(':', pos)
	if l == -1:
		print(-1)
		return
	pos = s.rfind(']')
	if pos == -1:
		print(-1)
		return
	r = s.rfind(':', 0, pos)
	if r == -1 or l >= r:
		print(-1)
		return
	ans = 4 + s.count('|', l, r)
	print(ans)
main()


a = input()
j = 0
l = len(a)
while j < l and a[j] != '[':
	j += 1
if j == l:
	print(-1)
else:
	m1 = j
	j = l - 1
	while j > m1 and a[j] != ']':
		j -= 1
	if j == l:
		print(-1)
	else:
		m2 = j
		j = m1
		while j < m2 and a[j] != ':':
			j += 1
		if j == m2:
			print(-1)
		else:
			m1 = j
			j = m2
			while j > m1 and a[j] != ':':
				j -= 1
			if j == m1:
				print(-1)
			else:
				t = 0
				for i in range(m1, j + 1):
					if a[i] == '|':
						t += 1
				print(t + 4)


inp = str(input())
n = len(inp)
tab = [-1] * 4
i = 0
while i < n:
	if inp[i] == '[':
		tab[0] = i
		break
	i += 1
while i < n:
	if inp[i] == ':':
		tab[1] = i
		break
	i += 1
i = n - 1
while i >= 0:
	if inp[i] == ']':
		tab[3] = i
		break
	i -= 1
i -= 1
while i >= 0:
	if inp[i] == ':':
		tab[2] = i
		break
	i -= 1
found = False
for e in tab:
	if tab[2] == tab[1] or tab != sorted(tab):
		print(-1)
		found = True
		break
	if e == -1:
		print(-1)
		found = True
		break
if not found:
	count = 0
	for k in range(tab[1], tab[2]):
		if inp[k] == '|':
			count += 1
	print(4 + count)


s = input()
(a, b, c, d) = (-1, -1, -1, -1)
ans = 0
for i in range(len(s)):
	if s[i] == '[':
		a = i
		break
for i in range(a, len(s)):
	if s[i] == ':' and i > a:
		b = i
		break
for i in range(len(s) - 1, 0, -1):
	if s[i] == ']':
		d = i
		break
for i in range(len(s) - 1, 0, -1):
	if s[i] == ':' and i < d:
		c = i
		break
if a < b < c < d and a >= 0 and (d < len(s)):
	print(4 + s[b:c].count('|'))
else:
	print('-1')


def maxLen(s):
	ln = len(s)
	le = 0
	ri = ln - 1
	removed = 0
	while le < ln and s[le] != '[':
		le += 1
		removed += 1
	if le == ln:
		return -1
	le += 1
	while le < ln and s[le] != ':':
		le += 1
		removed += 1
	if le == ln:
		return -1
	while ri >= 0 and s[ri] != ']':
		ri -= 1
		removed += 1
	if ri < 0:
		return -1
	ri -= 1
	while ri >= 0 and s[ri] != ':':
		ri -= 1
		removed += 1
	if ri < 0:
		return -1
	if le >= ri:
		return -1
	le += 1
	ri -= 1
	while le <= ri:
		if s[le] != '|':
			removed += 1
		le += 1
	return ln - removed
print(maxLen(input()))


import re
s = input()
si = s[::-1]

def sol():
	res = 4
	l = s.find('[')
	if l == -1:
		return -1
	l = s.find(':', l + 1)
	if l == -1:
		return -1
	r = si.find(']')
	if r == -1:
		return -1
	r = si.find(':', r + 1)
	if r == -1:
		return -1
	r = len(s) - r
	if r - 1 <= l:
		return -1
	for i in range(l, r):
		if s[i] == '|':
			res += 1
	return res
print(sol())


s = input()
f1 = False
f2 = False
l1 = -1
for l in range(len(s)):
	if f1 == False and s[l] == '[':
		f1 = True
	elif f1 == True and s[l] == ':':
		f2 = True
		l1 = l
		break
g1 = False
g2 = False
r1 = -1
for r in range(len(s) - 1, -1, -1):
	if g1 == False and s[r] == ']':
		g1 = True
	elif g1 == True and s[r] == ':':
		g2 = True
		r1 = r
		break
if (l1 == -1 or r1 == -1) or r1 <= l1:
	print(-1)
else:
	ans = 4
	for i in range(l1 + 1, r1):
		if s[i] == '|':
			ans += 1
	print(ans)


def check(sub):
	x = s.find('[')
	y = s.rfind(']')
	if x == -1 or y == -1:
		return [0, 0]
	return [x, y]

def amount(f):
	return f.count('|') + 4
s = input()
l = s.find('[')
r = s.rfind(']')
now = 0
if l == -1 or r == -1:
	print(-1)
else:
	s = s[l + 1:r]
	if s.count(':') < 2:
		print(-1)
	else:
		l = s.find(':')
		r = s.rfind(':')
		print(s[l + 1:r].count('|') + 4)


s = input()
flag = 0
count = 0
l1 = []
colonz = 0
for c in s:
	if c == '[':
		flag = 1
	if flag == 1:
		if c == ']' or c == '|' or c == ':':
			if c == ':':
				colonz += 1
			l1.append(c)
		else:
			count += 1
	else:
		count += 1
ind = len(l1) - 1
for c in l1[::-1]:
	if c == ']':
		break
	else:
		ind -= 1
if flag == 0:
	print(-1)
elif ind == -1:
	print(-1)
else:
	l1 = l1[:ind + 1]
	if l1.count(':') < 2:
		print(-1)
	else:
		for i in range(0, len(l1)):
			if l1[i] == ':':
				ind1 = i
				break
		for i in range(len(l1) - 1, -1, -1):
			if l1[i] == ':':
				ind2 = i
				break
		print(4 + len(l1[ind1:ind2 + 1]) - l1[ind1:ind2 + 1].count(':') - l1[ind1:ind2 + 1].count(']'))


s = input()
if s.count('[') > 0 and s.count(']') > 0 and (s.count(':') > 1):
	l = 0
	r = -1
	de = 0
	while s[l] != '[':
		l += 1
	while s[r] != ']':
		r -= 1
	de += l
	de += -r - 1
	dots = []
	bad = 0
	for i in range(l + 1, len(s) + r):
		if s[i] == ':':
			dots.append(i)
	if len(dots) >= 2:
		for i in range(dots[0] + 1, dots[-1]):
			if s[i] != '|':
				bad += 1
		de += bad
		de += dots[0] - l - 1
		de += len(s) + r - dots[-1] - 1
		print(len(s) - de)
	else:
		print(-1)
else:
	print(-1)


line = input()
s = ''
for char in line:
	if char == '[' or char == ']' or char == ':' or (char == '|'):
		s += char
f = 1
s = s[s.index('[') + 1:] if '[' in s else 0
if s == 0:
	print(-1)
else:
	if s.count(':') < 2 or ']' not in s:
		print(-1)
		exit()
	try:
		s = s[s.index(':') + 1:]
		s = s[::-1]
		s = s[s.index(']') + 1:]
		s = s[s.index(':') + 1:]
	except:
		print(-1)
		exit()
	print(s.count('|') + 4)


s = input()
l = len(s)
left_colon_pos = None
left_bracket_pos = None
right_colon_pos = None
right_bracket_pos = None
for i in range(l):
	if left_bracket_pos is None and s[i] == '[':
		left_bracket_pos = i
	if left_bracket_pos is not None and s[i] == ':':
		left_colon_pos = i
	if left_bracket_pos is not None and left_colon_pos is not None:
		break
for i in range(l - 1, 0, -1):
	if right_bracket_pos is None and s[i] == ']':
		right_bracket_pos = i
	if right_bracket_pos is not None and s[i] == ':':
		right_colon_pos = i
	if right_bracket_pos is not None and right_colon_pos is not None:
		break
if left_colon_pos is None or right_colon_pos is None or (not left_colon_pos < right_colon_pos):
	print(-1)
else:
	c = len(list(filter(lambda x: x == '|', s[left_colon_pos:right_colon_pos])))
	print(c + 4)


import sys

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = sys.stdin.readline().split()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_int(self):
		return int(self.next())

	def solve(self):
		s = self.next()
		r = 4
		i = 0
		l = len(s)
		while i < l and s[i] != '[':
			i += 1
		if i == l:
			print(-1)
			return
		while i < l and s[i] != ':':
			i += 1
		if i == l:
			print(-1)
			return
		j = l - 1
		while j > i and s[j] != ']':
			j -= 1
		if i == j:
			print(-1)
			return
		while j > i and s[j] != ':':
			j -= 1
		if i == j:
			print(-1)
			return
		for k in range(i, j):
			if s[k] == '|':
				r += 1
		print(r)
Main().solve()


s = list(input())
(start, end) = (-1, -1)
for i in range(len(s)):
	if s[i] == '[':
		start = i
		break
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']':
		end = i
		break
count = 2
ma = 0
for i in range(start + 1, end):
	if s[i] == ':' and count == 2:
		count += 1
	elif s[i] == '|' and count > 2:
		count += 1
	elif s[i] == ':' and count > 2:
		count += 1
		if count > ma:
			ma = count
		count -= 1
if ma < 4 or start == -1 or end == -1:
	print(-1)
else:
	print(ma)


def ba(s):
	c1 = s.find('[')
	c2 = s.find(':', c1 + 1)
	c3 = s.rfind(']', c2 + 1)
	c4 = s.rfind(':', c2 + 1, c3)
	if -1 in [c1, c2, c3, c4]:
		return -1
	return s.count('|', c2, c4) + 4
print(ba(input()))


import sys
s = input()
st = s.find('[')
if st == -1:
	print(-1)
	return
s = s[st + 1:]
st = s.find(':')
if st == -1:
	print(-1)
	return
s = s[st + 1:]
s = s[::-1]
st = s.find(']')
if st == -1:
	print(-1)
	return
s = s[st + 1:]
st = s.find(':')
if st == -1:
	print(-1)
	return
s = s[st + 1:]
x = s.count('|')
print(x + 4 if x >= 0 else -1)


s = input()
lens = len(s)
(Obracket, Cbracket) = (lens, -1)
(Colon, Line) = ([], [])
for i in range(lens):
	if s[i] == '[':
		Obracket = min(i, Obracket)
	if s[i] == ']':
		Cbracket = max(i, Cbracket)
if Obracket > Cbracket:
	print(-1)
else:
	leftColon = -1
	rightColon = lens
	for i in range(Obracket, Cbracket + 1):
		if s[i] == ':':
			leftColon = i
			break
	if leftColon == -1:
		print(-1)
	else:
		for i in reversed(range(leftColon + 1, Cbracket + 1)):
			if s[i] == ':':
				rightColon = i
				break
		if rightColon == lens:
			print(-1)
		else:
			LineNum = 0
			for i in range(leftColon + 1, rightColon):
				if s[i] == '|':
					LineNum += 1
			print(LineNum + 4)


s = input()
s = list(s)
f1 = 1
for i in range(len(s)):
	if s[i] == '[':
		s = s[i:]
		f1 = 0
		break
if f1:
	print('-1')
	exit()
f2 = 1
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']':
		s = s[:i + 1]
		f2 = 0
		break
if f2:
	print('-1')
	exit()
f3 = 1
for i in range(len(s)):
	if s[i] == ':':
		s[i] = '*'
		s = list('[') + s[i:]
		f3 = 0
		break
if f3:
	print('-1')
	exit()
f4 = 1
for i in range(len(s) - 1, -1, -1):
	if s[i] == ':':
		s = s[:i + 1] + list(']')
		f4 = 0
		break
if f4:
	print('-1')
	exit()
for i in range(2, len(s) - 2):
	if s[i] != '|':
		s[i] = '+'
l = 0
for i in range(len(s)):
	if s[i] != '+':
		l = l + 1
print(l)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
N = 10 ** 6 + 7

def fun(s):
	if s == -1:
		return s
	fb = False
	for i in range(len(s)):
		if fb and s[i] == ':':
			return s[i + 1:].replace('[', '').replace(']', '[')[::-1]
		elif s[i] == '[':
			fb = True
	return -1
s = fun(fun(S()))
print(s if s == -1 else s.count('|') + 4)


o = input()

def sol(o):

	def find_pre(o):
		start = o.find('[')
		if start == -1:
			return -1
		second = o.find(':', start)
		if second == -1:
			return -1
		return second

	def find_suf(o):
		start = o.find(']')
		if start == -1:
			return -1
		second = o.find(':', start)
		if second == -1:
			return -1
		return second
	b = find_pre(o)
	o = o[b + 1:]
	y = find_suf(o[::-1])
	o = o[:len(o) - 1 - y]
	if b == -1 or y == -1:
		return -1
	fill = o.count('|')
	res = fill + 4
	return res
print(sol(o))


s = str(input())
a1 = 0
a2 = 0
b1 = 0
b2 = 0
u = 0
t = 0
n = len(s)
for i in range(n):
	if s[i] == '[' and t == 0:
		a1 = i
		t = 1
	if s[i] == ':' and t == 1:
		b1 = i
		t = 2
for i in range(n):
	if s[n - 1 - i] == ']' and t == 2:
		a2 = n - 1 - i
		t = 3
	if s[n - 1 - i] == ':' and t == 3:
		b2 = n - 1 - i
		t = 4
if t == 4 and b1 < b2:
	for i in range(n):
		if s[i] == '|' and i > b1 and (i < b2):
			u += 1
	print(4 + u)
else:
	print(-1)


s = input()
l = len(s)
a = s.find('[')

def do(a, l, s):
	if a == -1 or l - a < 4:
		return -1
	s = s[a:]
	e = s[::-1].find(']')
	if e == -1:
		return -1
	e = len(s) - s[::-1].find(']') - 1
	s = s[:e]
	a = s.find(':')
	e = len(s) - s[::-1].find(':') - 1
	ans = 2
	if a == -1 or e == -1 or a == e:
		return -1
	ans = 4 + s[a:e].count('|')
	return ans
print(do(a, l, s))


import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

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

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

def nu():
	return int(input())
mm = 1000000007
t = 1
for it in range(t):
	s = input()
	x = '[:'
	y = ']:'
	c = 0
	ff = True
	ind = [0] * 4
	xp = 0
	for i in range(len(s)):
		if s[i] == x[c]:
			c += 1
			ind[xp] = i
			xp += 1
		if c == 2:
			break
	if c != 2:
		ff = False
	c = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] == y[c]:
			c += 1
			ind[xp] = i
			xp += 1
		if c == 2:
			break
	if c != 2:
		ff = False
	if ff == True:
		if ind[3] <= ind[1]:
			ff = False
	if ff == False:
		print(-1)
	else:
		vv = 0
		for i in range(ind[1], ind[3] + 1):
			if s[i] == '|':
				vv += 1
		print(vv + 4)


string = input()
length = len(string)
openBracketFound = False
closeBracketFound = False
legalFlag = False
count = 0
for i in range(length):
	if string[i] == '[' and (not openBracketFound):
		openBracketFound = True
		count += 1
	elif string[i] == ':' and openBracketFound:
		count += 1
		legalFlag = True
		break
if not legalFlag:
	print(-1)
	exit(0)
legalFlag = False
for j in range(length - 1, i, -1):
	if string[j] == ']' and (not closeBracketFound):
		closeBracketFound = True
		count += 1
	elif string[j] == ':' and closeBracketFound:
		count += 1
		legalFlag = True
		break
if not legalFlag:
	print(-1)
	exit(0)
for k in range(i + 1, j):
	if string[k] == '|':
		count += 1
print(count)


st = input()
need = 0
cnt = 0
ok = 0
fst = 10000000
lst = 0
reed = 0
l = len(st)
for i in range(l - 1):
	if need == 0 and st[i] == '[':
		need += 1
		cnt += 1
	elif need == 1 and st[i] == ':':
		fst = i
		cnt += 1
		break
for i in range(l - 1, fst, -1):
	if reed == 0 and st[i] == ']':
		reed += 1
		cnt += 1
	elif reed == 1 and st[i] == ':':
		lst = i
		reed += 1
		cnt += 1
	elif reed == 2 and st[i] == '|':
		cnt += 1
if fst < lst:
	print(cnt)
else:
	print(-1)


s = input()
(l, h) = (s.find('['), s.rfind(']'))
if l > h or l == -1 or h == -1:
	print(-1)
else:
	cL = s.find(':', l, h)
	cH = s.rfind(':', l, h)
	if cH <= cL:
		print(-1)
	else:
		ans = s.count('|', cL, cH) + 4
		print(ans)


s = input()
i = 0
N = len(s)
while i < N and s[i] != '[':
	i += 1
while i < N and s[i] != ':':
	i += 1
j = N - 1
while j >= 0 and s[j] != ']':
	j -= 1
while j >= 0 and s[j] != ':':
	j -= 1
if i >= j:
	print(-1)
else:
	num = 4
	for k in range(i, j):
		if s[k] == '|':
			num += 1
	print(num)


s = input()
n = len(s)
if ']' not in s:
	print(-1)
	exit()
else:
	b2 = n - 1 - s[::-1].index(']')
if '[' not in s:
	print(-1)
	exit()
else:
	b1 = s.index('[')
if s[b1 + 1:b2].count(':') < 2:
	print(-1)
	exit()
else:
	d1 = b1 + 1 + s[b1 + 1:b2].index(':')
	d2 = b2 - 1 - s[b2 - 1:b1:-1].index(':')
if b1 < d1 and d1 < d2 and (d2 < b2):
	c = 0
	for i in range(d1 + 1, d2):
		if s[i] == '|':
			c += 1
	print(c + 4)
else:
	print(-1)


s = input()
lb = s.find('[')
rb = s.rfind(']')
lc = s.find(':', lb, rb)
rc = s.rfind(':', lb, rb)
print(s[lc:rc].count('|') + 4 if lc != rc and rb != -1 else -1)


import sys
S = input()
if '[' in S:
	a = S.index('[')
else:
	print(-1)
	sys.exit()
if ']' in S:
	d = S.rindex(']')
else:
	print(-1)
	sys.exit()
if ':' in S[a:d]:
	b = S[a:].index(':') + a
else:
	print(-1)
	sys.exit()
if ':' in S[:d]:
	c = S[:d].rindex(':')
else:
	print(-1)
	sys.exit()
if b == c:
	print(-1)
	sys.exit()
ANS = 0
if '|' in S[b:c]:
	ANS = S[b:c].count('|')
print(ANS + 4)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		s = S()
		l = len(s)
		li = -1
		for i in range(l):
			if s[i] == '[':
				li = i
				break
		if li < 0:
			rr.append(-1)
			continue
		for i in range(li + 1, l):
			if s[i] == ':':
				li = i
				break
		if s[li] != ':':
			rr.append(-1)
			continue
		ri = l
		for i in range(l - 1, -1, -1):
			if s[i] == ']':
				ri = i
				break
		if ri == l:
			rr.append(-1)
			continue
		for i in range(ri - 1, -1, -1):
			if s[i] == ':':
				ri = i
				break
		if s[ri] != ':' or li >= ri:
			rr.append(-1)
			continue
		if li == ri:
			rr.append(l - 3)
		else:
			c = len([_ for _ in s[li + 1:ri] if _ == '|'])
			rr.append(c + 4)
	return JA(rr, '\n')
print(main())


import re
st = input()
if st.find('[', 0) < 0 or st.rfind(']') < 0 or st.find('[', 0) > st.rfind(']'):
	print(-1)
	exit(0)
st = st[st.find('[', 0):st.rfind(']')]
if st.find(':') == st.rfind(':'):
	print(-1)
	exit(0)
st = st[st.find(':', 0):st.rfind(':')]
print(len(re.sub('[^|]', '', st)) + 4)


s = input()
coord_open = s.find('[')
coord_close = s.rfind(']')
coord_left = s.find(':', coord_open, coord_close)
coord_right = s.rfind(':', coord_open, coord_close)
if coord_left != -1 and coord_open != -1 and (coord_right != -1) and (coord_close != -1) and (coord_open < coord_left < coord_right < coord_close):
	counter = 0
	for i in range(coord_left + 1, coord_right):
		if s[i] == '|':
			counter += 1
	print(4 + counter)
else:
	print(-1)


s = input()
a = s.find('[')
b = s.find(':', a)
c = s.rfind(']')
d = s.rfind(':', b, c)
if a < b < d < c:
	print(4 + s[b:d].count('|'))
else:
	print(-1)


s = input()
left = s.find('[')
if left == -1:
	print(-1)
else:
	left_colon = s[left:].find(':')
	if left_colon == -1:
		print(-1)
	else:
		left_colon += left
		right = s[left_colon:].rfind(']')
		if right == -1:
			print(-1)
		else:
			right += left_colon
			right_colon = s[left_colon + 1:right].rfind(':')
			if right_colon == -1:
				print(-1)
			else:
				right_colon += left_colon + 1
				print(4 + s[left_colon:right_colon].count('|'))


s = input()
fo = -1
for i in range(len(s)):
	if s[i] == '[':
		fo = i
		break
if fo == -1:
	print(-1)
	exit(0)
fc = -1
for i in range(fo, len(s)):
	if s[i] == ']':
		fc = i
if fc == -1:
	print(-1)
	exit(0)
fd = -1
for i in range(fo, fc):
	if s[i] == ':':
		fd = i
		break
if fd == -1:
	print(-1)
	exit(0)
sd = -1
for i in range(fd + 1, fc):
	if s[i] == ':':
		sd = i
if sd == -1:
	print(-1)
	exit(0)
ans = 4
for i in range(fd, sd):
	if s[i] == '|':
		ans += 1
print(ans)


s = input()
n = len(s)
a = s.find('[')
b = s.find(':', a)
c = s.rfind(']')
d = s.rfind(':', 0, c)
if a < b < d < c:
	print(4 + s[b:d].count('|'))
else:
	print(-1)


s = list(input())
p = 0
start = len(s)
end = 0
for i in range(len(s)):
	if s[i] == '[':
		p = 1
	if s[i] == ':':
		if p == 1:
			start = i
			break
s.reverse()
p = 0
for i in range(len(s)):
	if s[i] == ']':
		p = 1
	if s[i] == ':':
		if p == 1:
			end = len(s) - i - 1
			break
s.reverse()
counter = 0
p = 0
for item in range(start + 1, end):
	if s[item] == '|':
		counter += 1
if start >= end:
	print(-1)
else:
	print(counter + 4)


import sys
s = input()
left = s.find('[')
right = s.rfind(']')
if left < 0 or right < 0:
	print(-1)
	sys.exit()
s = s[left:right + 1]
left = s.find(':')
right = s.rfind(':')
if left < 0 or right < 0 or left == right:
	print(-1)
	sys.exit()
s = s[left:right + 1]
print(s.count('|') + 4)


from sys import stdin
import pprint
input_string = stdin.readline()
index_of_open = 0
index_of_closed = 0
first_double_dots = 0
second_double_dots = 0
num_of_lines = 0
index = 0
while (not index_of_open or not first_double_dots) and index < input_string.__len__():
	if input_string[index] == '[' and (not index_of_open):
		index_of_open = index + 1
	elif input_string[index] == ':' and index_of_open:
		first_double_dots = index + 1
	index += 1
index = input_string.__len__() - 1
while (not index_of_closed or not second_double_dots) and index >= 0:
	if input_string[index] == ']' and (not index_of_closed):
		index_of_closed = index + 1
	elif input_string[index] == ':' and index_of_closed:
		second_double_dots = index + 1
	index -= 1
if index_of_closed - index_of_open > 2 and first_double_dots and second_double_dots and (first_double_dots < second_double_dots):
	for i in range(first_double_dots, second_double_dots):
		if input_string[i] == '|':
			num_of_lines += 1
	print(4 + num_of_lines)
else:
	print(-1)


s = input()
(c1, c2, c3, c4) = ('[', ':', '|', ']')
(ct1, ct2, ct3, ct4) = (-1, -1, -1, -1)
for (i, c) in enumerate(s):
	if c == c1:
		ct1 = i
	if ct1 > -1 and c == c2:
		ct2 = i
		break
for i in range(len(s) - 1, -1, -1):
	c = s[i]
	if c == c4:
		ct4 = i
	if ct4 > -1 and c == c2:
		ct3 = i
		break
if ct2 == -1 or ct3 == -1:
	print(-1)
elif ct2 >= ct3:
	print(-1)
else:
	ct = 0
	for i in range(ct2 + 1, ct3):
		if s[i] == c3:
			ct += 1
	print(ct + 4)


s = input()
leng = len(s)
flb = -1
flc = -1
lrb = -1
lrc = -1
j = 0
while j < leng:
	if flb == -1 and s[j] == '[':
		flb = j
	if flb != -1 and flc == -1 and (s[j] == ':'):
		flc = j
		break
	j += 1
j = leng - 1
while j >= 0:
	if lrb == -1 and s[j] == ']':
		lrb = j
	if lrb != -1 and lrc == -1 and (s[j] == ':'):
		lrc = j
		break
	j -= 1
if flb == -1 or flc == -1 or lrb == -1 or (lrc == -1):
	print(-1)
elif flb > lrb:
	print(-1)
else:
	flag = True
	count = 0
	if flc > lrb or lrc > lrb:
		flag = False
	if flc == lrc:
		flag = False
	for i in range(flc + 1, lrc):
		if s[i] == '|':
			count += 1
	if flag == True:
		print(count + 4)
	else:
		print(-1)


s = input()
flag1 = False
flag2 = False
for i in range(len(s)):
	if s[i] == '[':
		flag1 = True
	if s[i] == ':' and flag1:
		ind = i + 1
		flag2 = True
	if flag2:
		break
if flag2 == False:
	print('-1')
else:
	main = s[len(s) - 1:i:-1]
	flag1 = False
	flag2 = False
	for i in range(len(main)):
		if main[i] == ']':
			flag1 = True
		if main[i] == ':' and flag1:
			ind = i + 1
			flag2 = True
		if flag2:
			break
	if flag2 == False:
		print('-1')
	else:
		count = 0
		for i in range(ind, len(main)):
			if main[i] == '|':
				count += 1
		print(count + 4)


s = list(input())
f = 100000000
l = 100000000
of = f
ol = l
cks = [False, False, False, False, False]
for i in range(0, len(s)):
	if s[i] == '[':
		cks[0] = True
	if cks[0] and s[i] == ':':
		cks[1] = True
		f = i
		break
for j in range(len(s) - 1, -1, -1):
	if s[j] == ']':
		cks[-1] = True
	if cks[-1] and s[j] == ':':
		l = j
		break
if f == of or l == ol or f >= l:
	print(-1)
else:
	ln = 0
	for i in range(f + 1, l):
		if s[i] == '|':
			ln += 1
	print(ln + 4)


s = input()
l = 0
end = 0
i = 1
while i <= len(s):
	if l == 0 and s[-i] == ']':
		l += 1
	elif l == 1 and s[-i] == ':':
		l += 1
		end = len(s) - i
		break
	i += 1
if l < 2:
	print(-1)
	return
for i in range(0, end):
	if l >= 4 and s[i] == '|':
		l += 1
	elif l == 2 and s[i] == '[':
		l += 1
	elif l == 3 and s[i] == ':':
		l += 1
if l >= 4:
	print(l)
else:
	print(-1)


s = input()
lb = s.find('[')
lc = lb + 1 + s[lb + 1:].find(':')
rb = s.rfind(']')
rc = s[:rb].rfind(':')
if not lb < lc < rc < rb or lb == -1:
	print(-1)
	exit()
print(4 + s[lc:rc].count('|'))


s = input()
try:
	L = s.index(':', s.index('['))
	R = s.rindex(':', L + 1, s.rindex(']', L))
	ans = s.count('|', L, R) + 4
except:
	ans = -1
print(ans)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
s = input().strip()
n = len(s)
res = 0
st = n
ed = -1
for i in range(n):
	if s[i] == '[':
		st = i
		break
for i in range(n - 1, -1, -1):
	if s[i] == ']':
		ed = i
		break
if ed <= st:
	print(-1)
	exit(0)
idx = []
for i in range(st, ed):
	if s[i] in [':', '|']:
		idx.append(i)
col1 = len(idx)
col2 = -1
for i in range(len(idx)):
	if s[idx[i]] == ':':
		col1 = idx[i]
		break
for i in range(len(idx) - 1, -1, -1):
	if s[idx[i]] == ':':
		col2 = idx[i]
		break
if col2 <= col1:
	print(-1)
else:
	print(4 + s[col1:col2].count('|'))


int_inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mul = lambda : map(int, input().split())
mulf = lambda : map(float, input().split())
seq = lambda : list(map(int, input().split()))
import math
from collections import Counter, defaultdict
m = list(input())
q = m[::-1]
k = ['[', ':', '|', ':', ']']
j = 0
n = len(m)
try:
	b = m[m.index('[') + 1:n - 1 - q.index(']')]
except:
	print(-1)
	exit()
q = b[::-1]
try:
	if b.count(':') > 1:
		d = b[b.index(':') + 1:len(b) - 1 - q.index(':')]
	else:
		m[len(m) + 10]
except:
	print(-1)
	exit()
print(4 + d.count('|'))


s = input()
s = ''.join((i for i in s if i in '[:]|'))
res = s.find('[')
if res == -1:
	print('-1')
	exit()
s = s[res:]
res = s.rfind(']')
if res == -1:
	print('-1')
	exit()
s = s[:res + 1]
if s.count(':') >= 2:
	f = s.find(':')
	l = s.rfind(':', f)
	count = s[f + 1:l].count('|')
	print(count + 4)
else:
	print('-1')


n = list(input())
i = 0
c = 0
b1 = 0
b2 = 0
j = len(n) - 1
while i < j:
	if len(n) >= 1 and n[i] == '[':
		b1 = 1
	else:
		i += 1
	if len(n) > 1 and n[j] == ']':
		b2 = 1
	else:
		j -= 1
	if b1 == 1 and b2 == 1:
		break
if i < j and b1 == 1 and (b2 == 1):
	b1 = 0
	b2 = 0
	while i < j:
		if len(n) > 1 and n[i] == ':':
			b1 = 1
		else:
			i += 1
		if i < j and n[j] == ':':
			b2 = 1
		else:
			j -= 1
		if b1 == 1 and b2 == 1:
			break
else:
	print(-1)
	c = 1
if c == 0 and b1 == 1 and (b2 == 1):
	b1 = 0
	b2 = 0
	d = 0
	while i < j:
		if n[i] == '|':
			d += 1
		i += 1
	print(d + 4)
elif c == 0:
	print(-1)


s = input()
a = s.find('[')
if a == -1:
	print(a)
	exit(0)
b = s.find(':', a)
if b == -1:
	print(b)
	exit(0)
c = s.rfind(']', b)
if c == -1:
	print(c)
	exit(0)
d = s.rfind(':', b + 1, c)
if d == -1:
	print(d)
	exit(0)
cnt = 0
for i in range(b, d):
	cnt += s[i] == '|'
print(cnt + 4)


s = input()
(start, end, l) = (len(s), -1, len(s))
flag = False
for i in range(l):
	if s[i] == '[':
		flag = True
	if flag and s[i] == ':':
		start = i
		break
flag = False
for i in range(l - 1, -1, -1):
	if s[i] == ']':
		flag = True
	if flag and s[i] == ':':
		end = i
		break
if start < end:
	ans = 4
	for i in range(start + 1, end):
		if s[i] == '|':
			ans += 1
	print(ans)
else:
	print(-1)


a = str(input())
x = len(a)
if '[' in a:
	p = a.index('[')
else:
	print('-1')
	exit()
q = a.find(':', p, x)
if q == -1:
	print('-1')
	exit()
v = a.rfind(']', q, x)
if v == -1:
	print('-1')
	exit(0)
w = a.rfind(':', q + 1, v)
if w == -1:
	print('-1')
	exit(0)
c = a.count('|', q, w)
print(c + 4)


s = input().strip()
ans = -1
fb = s.find('[')
if fb >= 0:
	fc = s.find(':', fb)
	if fc >= 0:
		lb = s.rfind(']', fc)
		if lb >= 0:
			lc = s.rfind(':', fc, lb)
			if lc > fc:
				ans = 4 + s[fc:lc].count('|')
print(ans)


s = input()
if '[' in s and ']' in s:
	a = s.index('[') + 1
	b = len(s) - s[::-1].index(']') - 1
else:
	print(-1)
	return
s = s[a:b]
if s.count(':') >= 2:
	a = s.index(':') + 1
	b = len(s) - s[::-1].index(':') - 1
else:
	print(-1)
	return
c = 0
for el in s[a:b]:
	if el == '|':
		c += 1
print(4 + c)


s = input()
cnt = 0
n = len(s)
for i in range(n):
	if s[i] == '[':
		cnt += 1
		idx1 = i
		break
if cnt == 0:
	print(-1)
else:
	for i in range(idx1 + 1, n):
		if s[i] == ':':
			cnt += 1
			idx2 = i
			break
	if cnt < 2:
		print(-1)
	else:
		flag = False
		for i in range(n - 1, idx2, -1):
			if s[i] == ']' and cnt == 2:
				cnt += 1
				idx3 = i
			if cnt == 3 and s[i] == ':':
				idx4 = i
				flag = True
				cnt += 1
				break
		if cnt < 4 and (not flag):
			print(-1)
		else:
			a = s[idx2 + 1:idx4]
			ans = 4 + a.count('|')
			print(ans)


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

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

def li():
	return list(mi())
s = input().strip()
n = len(s)
ans = -1
fb = s.find('[')
if fb >= 0:
	fc = s.find(':', fb)
	if fc >= 0:
		lb = s.rfind(']')
		if lb > fc:
			lc = s.rfind(':', 0, lb)
			if lc > fc:
				ans = 4 + s[fc:lc].count('|')
print(ans)


s = input()
t_d = 0
try:
	left = -1
	was_b = False
	for i in range(len(s)):
		if s[i] == '[' and (not was_b):
			was_b = True
			continue
		if s[i] == ':' and was_b:
			left = i
			break
		t_d += 1
	if left == -1:
		raise ArithmeticError()
	right = -1
	was_b = False
	for i in range(len(s) - 1, -1, -1):
		if s[i] == ']' and (not was_b):
			was_b = True
			continue
		if s[i] == ':' and was_b:
			right = i
			break
		t_d += 1
	if right == -1 or right <= left:
		raise ArithmeticError()
	for i in range(left + 1, right):
		if s[i] != '|':
			t_d += 1
	print(len(s) - t_d)
except:
	print(-1)


import sys
s = sys.stdin.readline()
ls = len(s)
l1 = s.find('[')
r1 = ls - 1 - s[::-1].find(']')
if l1 == -1 or r1 == ls or l1 > r1:
	print(-1)
	exit(0)
l2 = s.find(':', l1 + 1, r1)
r2 = r1 - 1 - s[r1 - 1:l1:-1].find(':')
if l2 == -1 or r2 == ls or l2 == r2:
	print(-1)
	exit(0)
print(4 + s.count('|', l2 + 1, r2))


def find_braces(s, i, j):
	while i < j:
		if s[i] != '[':
			i += 1
		if s[j] != ']':
			j -= 1
		if s[i] == '[' and s[j] == ']':
			return (i, j)
			break
	return (-1, -1)

def find_colons(s, i, j):
	while i < j:
		if s[i] != ':':
			i += 1
		if s[j] != ':':
			j -= 1
		if i != j and s[i] == s[j] == ':':
			return (i, j)
	return (-1, -1)
s = input()
(i, j) = (0, len(s) - 1)
(i, j) = find_braces(s, i, j)
(i2, j2) = find_colons(s, i, j)
if i2 == j2 == -1:
	print(-1)
else:
	remove = i + (len(s) - j - 1) + (i2 - i - 1) + (j - j2 - 1)
	i2 += 1
	j2 -= 1
	while i2 < j2:
		if s[i2] != '|':
			remove += 1
		if s[j2] != '|':
			remove += 1
		i2 += 1
		j2 -= 1
	if i2 == j2 and s[i2] != '|':
		remove += 1
	print(len(s) - remove)


def main():
	(l, c) = (list(input()), ' ')
	try:
		while c != ']':
			c = l.pop()
		while c != ':':
			c = l.pop()
		l.reverse()
		while c != '[':
			c = l.pop()
		while c != ':':
			c = l.pop()
	except IndexError:
		print(-1)
	else:
		print(l.count('|') + 4)
main()


s = str(input())
x = s.find('[')
y = s.rfind(']')
x1 = s[x:y].find(':')
y1 = s[x:y].rfind(':')
m = s[x1 + x:x + y1 + 1].count('|')
if x > -1 and y > -1 and (y1 > -1) and (x1 > -1) and (x1 != y1):
	print(4 + m)
else:
	print(-1)


from sys import stdin, stdout
from operator import itemgetter, attrgetter

def no(s):
	print(s)
s = input()
if '[' not in s:
	print(-1)
else:
	i1 = s.index('[')
	s = s[i1:]
	if ']' not in s:
		print(-1)
	else:
		rs = s[::-1]
		i2 = rs.index(']')
		rs = rs[i2:]
		s = rs[::-1]
		i1 = s.index('[')
		i2 = s.index(']')
		if s.count(':') <= 1:
			print(-1)
		else:
			i3 = s.index(':')
			rs = s[::-1]
			i4 = rs.index(':')
			i4 = len(rs) - i4 - 1
			print(s[i3:i4].count('|') + 4)


s = input()
if s.find('[') == -1:
	print(-1)
	exit(0)
s = s[s.find('[') + 1:]
if s.find(':') == -1:
	print(-1)
	exit(0)
s = s[s.find(':') + 1:]
s = s[::-1]
if s.find(']') == -1:
	print(-1)
	exit(0)
s = s[s.find(']') + 1:]
if s.find(':') == -1:
	print(-1)
	exit(0)
s = s[s.find(':') + 1:]
s = s[::-1]
print(4 + s.count('|'))


def B():
	s = input()
	o_bracket = set()
	c_bracket = set()
	colon = set()
	for i in range(len(s)):
		if s[i] == '[':
			o_bracket.add(i)
		if s[i] == ']':
			c_bracket.add(i)
	if len(o_bracket) * len(c_bracket) == 0:
		print(-1)
		return
	(l, r) = (min(o_bracket), max(c_bracket))
	for i in range(l, r + 1):
		if s[i] == ':':
			colon.add(i)
	if len(colon) < 2:
		print(-1)
		return
	(ll, rr) = (min(colon), max(colon))
	count_vl = 0
	for i in range(ll, rr + 1):
		if s[i] == '|':
			count_vl += 1
	print(count_vl + 4)
B()


s = input()
if '[' in s and ']' in s and (':' in s):
	e = s.count(':')
	if e < 2:
		print(-1)
	else:
		a = s.index('[')
		b = len(s) - 1 - s[::-1].index(']')
		if b < a:
			print(-1)
		elif s[a + 1:b].count(':') < 2:
			print(-1)
		else:
			st1 = True
			count = 0
			for i in range(a + 1, b):
				if st1 and s[i] == ':':
					pos1 = i
					st1 = False
				if s[i] == ':':
					pos2 = i
			for i in range(pos1 + 1, pos2):
				if s[i] == '|':
					count += 1
			print(count + 4)
else:
	print(-1)


s = input()
try:
	s = s[s.index('['):s.rindex(']') + 1]
	s = s.replace(s[s.index('[') + 1:s.index(':')], '', 1).replace(s[s.rindex(':') + 1:s.rindex(']')], '', 1)
except:
	print(-1)
	exit()
if s.count(':') < 2:
	print(-1)
else:
	print(4 + s.count('|'))


s = input()
two = ''
si = s.find(':', s.find('['))
rs = s[::-1]
ei = len(s) - rs.find(':', rs.find(']')) - 1
if si == -1 or rs.find(':', rs.find(']')) == -1 or ei <= si:
	print(-1)
else:
	count = 0
	for i in range(si + 1, ei):
		if s[i] == '|':
			count += 1
	print(4 + count)


s = input()
try:
	b1 = s.index('[')
	d1 = s.index(':', b1)
	b2 = s.rindex(']')
	d2 = s.rindex(':', d1 + 1, b2)
	h = s.count('|', d1, d2)
	print(h + 4)
except (ValueError, IndexError):
	print(-1)


s = list(input())
for i in range(len(s)):
	if s[i] == '[':
		index = i
		break
else:
	print(-1)
	exit()
s = s[index + 1:]
for i in range(len(s)):
	if s[i] == ':':
		index = i
		break
else:
	print(-1)
	exit()
s = s[index + 1:]
s = s[::-1]
for i in range(len(s)):
	if s[i] == ']':
		index = i
		break
else:
	print(-1)
	exit()
s = s[index + 1:]
for i in range(len(s)):
	if s[i] == ':':
		index = i
		break
else:
	print(-1)
	exit()
s = s[index + 1:]
count = s.count('|')
print(count + 4)


s = input()
stack = []
s = list(s)
sc = 0
ec = 0
ls = 0
cc = 0
lc = -1
ml = -1
for i in range(len(s)):
	if sc == 0:
		if s[i] == '[':
			ls += 1
			stack.append('[')
			sc = 1
	elif cc == 0:
		if s[i] == ':':
			ls += 1
			cc += 1
			stack.append(':')
	elif s[i] == '|':
		ls += 1
		stack.append('|')
	elif cc >= 1 and s[i] == ':':
		cc = 2
		lc = ls
	elif s[i] == ']':
		if cc == 2:
			ml = max(ml, lc + 2)
print(ml)


def find_first(s, start, c):
	ans = -1
	for i in range(start, len(s)):
		if s[i] == c:
			return i
	print(-1)
	exit(0)

def find_last(s, start, finish, c):
	ans = -1
	for i in range(start, finish, -1):
		if s[i] == c:
			return i
	print(-1)
	exit(0)

def main():
	s = input()
	ft1 = find_first(s, 0, '[')
	ft2 = find_first(s, ft1, ':')
	ft4 = find_last(s, len(s) - 1, ft2, ']')
	ft3 = find_last(s, ft4, ft2, ':')
	cnt = 0
	for i in range(ft2, ft3):
		if s[i] == '|':
			cnt += 1
	print(cnt + 4)
main()


s = input()
try:
	st = s.index('[')
	s = s[st:]
	fn = s.rindex(']')
	s = s[:fn]
	st1 = s.index(':')
	fn2 = s.rindex(':')
	if fn2 == st1:
		raise ValueError
	else:
		print(4 + s[st1:fn2].count('|'))
except Exception:
	print(-1)


def main():
	s = input()
	if s.count('[') == 0 or s.count(']') == 0:
		print(-1)
		return
	t = s[s.find('['):s.rfind(']') + 1]
	if t.count(':') < 2:
		print(-1)
		return
	t = t[t.find(':'):t.rfind(':') + 1]
	print(4 + t.count('|'))
main()


s = input()
(l, r) = (s.find('['), s.rfind(']'))
if l == -1 or r == -1:
	print(-1)
else:
	news = s[l:r + 1]
	(l2, r2) = (news.find(':'), news.rfind(':'))
	if l2 == r2:
		print(-1)
	else:
		v = news[l2:r2 + 1].count('|')
		print(v + 4)


n = input()
lam = n[::-1]
if n.count('[') == 0 or n.count(']') == 0:
	print(-1)
else:
	jam = n.index('[')
	kj = lam.index(']')
	pam = len(n) - (kj + 1)
	if pam < jam:
		print(-1)
	else:
		ham = n[jam:pam + 1]
		ham = list(ham)
		noo = ham.count(':')
		if noo == 0 or noo == 1:
			print('-1')
		else:
			ol = ham.index(':')
			sam = ham[::-1]
			po = sam.index(':')
			jh = len(ham) - (po + 1)
			hg = ham[ol:jh + 1].count('|')
			print(hg + 4)


import sys
s = input()
try:
	o = s.index('[')
	c = len(s) - 1 - s[-1::-1].index(']')
except:
	print('-1')
	sys.exit()
if o >= c:
	print('-1')
	sys.exit()
s = s[o:c]
try:
	o = s.index(':')
	c = len(s) - 1 - s[-1::-1].index(':')
except:
	print('-1')
	sys.exit()
if o >= c:
	print('-1')
	sys.exit()
s = s[o:c]
count = s.count('|')
print(count + 4)


s = input()
if s.count('[') == 0 or s.count(']') == 0 or s.count(':') == 0:
	print(-1)
else:
	a = s.index('[')
	B = s[::-1].index(']')
	b = len(s) - B - 1
	Z = s[a + 1:b]
	if Z.count(':') < 2:
		print(-1)
	else:
		c = Z.index(':')
		D = Z[::-1].index(':')
		d = len(Z) - D - 1
		R = Z[c + 1:d]
		r = R.count('|')
		S = r + 4
		print(S)


s = input()
le = len(s)
l = s.find('[', 0, -1)
r = s.rfind(']', l, le)
if l == -1 or r == -1:
	print(-1)
else:
	l = s.find(':', l, r)
	r = s.rfind(':', l + 1, r)
	if l == -1 or r == -1:
		print(-1)
	else:
		print(s.count('|', l + 1, r) + 4)


data = list(input())
try:
	data = data[data.index('['):]
	end_index = len(data) - data[::-1].index(']') - 1
	first_colon = data[:end_index].index(':')
	second_colon = len(data[:end_index]) - data[:end_index][::-1].index(':') - 1
except:
	import sys
	print(-1)
	sys.exit()
if first_colon != second_colon:
	print(data[first_colon:second_colon].count('|') + 4)
else:
	print(-1)


x = input()
temp = ['[', ':', ']']
f = 0
ans = 0
first = 0
for i in range(len(x)):
	if x[i] == temp[f]:
		f += 1
		ans += 1
	if f == 2:
		first = i + 1
		break
d = 2
second = len(x) - 1
for i in range(len(x) - 1, first - 1, -1):
	if x[i] == temp[d]:
		d -= 1
		ans += 1
	if d == 0:
		second = i
		break
for i in range(first, second):
	if x[i] == '|':
		ans += 1
if f == 2 and d == 0:
	print(ans)
else:
	print(-1)


s = input()
st = 0
en = len(s)
st = s.find('[')
if st != -1:
	FIND = False
	for i in range(en - 1, st - 1, -1):
		if s[i] == ']':
			FIND = True
			en = i
			break
	if FIND:
		if s[st + 1:en].count(':') >= 2:
			for i in range(st + 1, en):
				if s[i] == ':':
					st = i
					break
			for i in range(en - 1, st, -1):
				if s[i] == ':':
					en = i
					break
			print(4 + s[st + 1:en].count('|'))
			exit()
print(-1)


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

def inar():
	return [int(el) for el in input().split()]

def main():
	arr = input().strip()
	n = len(arr)
	ans = 0
	(start, end) = (0, 0)
	(c1, c2, c3, c4) = (False, False, False, False)
	for i in range(n):
		if arr[i] == '[':
			ans += i
			start = i + 1
			c1 = True
			break
	for i in range(n - 1, -1, -1):
		if arr[i] == ']':
			ans += n - i - 1
			end = i - 1
			c2 = True
			break
	for i in range(start, end + 1):
		if arr[i] == ':':
			ans += i - start
			start = i + 1
			c3 = True
			break
	for i in range(end, start - 1, -1):
		if arr[i] == ':':
			ans += end - i
			end = i - 1
			c4 = True
			break
	for i in range(start, end + 1):
		if arr[i] != '|':
			ans += 1
	if c1 and c2 and c3 and c4:
		print(n - ans)
	else:
		print(-1)
main()


s = input()
L = len(s)
res = 0
left = -1
left_c = -1
right = -1
right_c = -1
for i in range(L):
	if s[i] == '[' and left == -1:
		left = i
	if s[i] == ':' and left != -1:
		left_c = i
		break
for i in range(L - 1, -1, -1):
	if s[i] == ']' and right == -1:
		right = i
	if s[i] == ':' and right != -1:
		right_c = i
		break
if left_c == -1 or right_c == -1:
	print(-1)
	quit()
if left == -1 or right == -1:
	print(-1)
	quit()
if right_c <= left_c:
	print(-1)
	quit()
if left >= right:
	print(-1)
	quit()
for i in range(L):
	if i >= left_c and i <= right_c:
		if s[i] == '|':
			res += 1
print(res + 4)


n = input()
s_o = -1
s_c = -1
for i in range(len(n)):
	if n[i] == '[':
		s_o = i
		break
for i in range(len(n) - 1, -1, -1):
	if n[i] == ']':
		s_c = i
		break
st = -1
fin = -1
a = 0
f = True
try:
	if (s_o >= s_c or s_c - s_o < 2) or (s_o == -1 or s_c == -1):
		f = False
	else:
		for i in range(s_o, s_c):
			if n[i] == ':':
				st = i
				break
		for i in range(s_c, s_o, -1):
			if n[i] == ':':
				if i > st:
					fin = i
				else:
					f = False
				break
		for i in range(st, fin):
			if n[i] == '|':
				a += 1
	if st == -1 or fin == -1:
		f = False
except IndexError:
	f = False
if f:
	print(a + 4)
else:
	print(-1)


s = input()
n = len(s)
f = 0
t = ''
i = 0
while i < n and s[i] != '[':
	i += 1
j = n - 1
while j >= 0 and s[j] != ']':
	j -= 1
k = i + 1
while k < n and s[k] != ':':
	k += 1
p = j - 1
while p >= 0 and s[p] != ':':
	p = p - 1
c = 0
q = k + 1
while q < p:
	if s[q] == '|':
		c += 1
	q += 1
if k >= p or i == n or j == -1 or (k == n):
	print('-1')
else:
	print(c + 4)


def cal():
	s = input()
	l = -1
	r = -1
	for i in range(len(s)):
		if s[i] == ']':
			r = i
		if s[i] == '[' and l == -1:
			l = i
	if l == -1 or r == -1:
		return -1
	u = -1
	v = -1
	for i in range(l, r):
		if s[i] == ':':
			if u == -1:
				u = i
			else:
				v = i
	if u == -1 or v == -1:
		return -1
	return s.count('|', u, v) + 4
print(cal())


import sys
s = input()
d = 0
(l1, l2, l3) = ([], [], [])
for i in range(0, len(s)):
	if s[i] == '[':
		l1.append(i)
	if s[i] == ':':
		l2.append(i)
	if s[i] == ']':
		l3.append(i)
try:
	x = l1[0]
	y = l3[len(l3) - 1]
	if x > y:
		sys.exit()
	for i in l2:
		if i > l1[0]:
			a = i
			break
	for i in range(len(l2) - 1, -1, -1):
		if l2[i] < y:
			b = l2[i]
			break
	for i in range(a + 1, b):
		if s[i] == '|':
			d = d + 1
	if a > y or b < x:
		sys.exit()
	print(4 + d if a != b else -1)
except:
	print(-1)


def factorise(m):
	ans = []
	p = 2
	while m != 1:
		if m % p != 0:
			p += 1
			continue
		e = 0
		while m % p == 0:
			m //= p
			e += 1
		ans.append([p, e])
		p += 1
	return ans

def mulmod(a, b, c):
	res = a * b
	if res >= c:
		res %= c
	return res

def mod_inverse(a, n):
	N = n
	xx = 0
	yy = 1
	y = 0
	x = 1
	while n > 0:
		q = a // n
		t = n
		n = a % n
		a = t
		t = xx
		xx = x - q * xx
		x = t
		t = yy
		yy = y - q * yy
		y = t
	x %= N
	x += N
	x %= N
	return x

def expo(a, b):
	x = 1
	y = a
	while b > 0:
		if b & 1:
			x = x * y
		y = y * y
		b >>= 1
	return x

def power(a, b, c):
	x = 1
	y = a
	while b > 0:
		if b & 1:
			x = mulmod(x, y, c)
		y = mulmod(y, y, c)
		b >>= 1
	return x

def init(p, pk):
	fact = []
	fact.append(1)
	for i in range(1, pk):
		red = i
		if red % p == 0:
			red = 1
		fact.append(mulmod(fact[i - 1], red, pk))
	return fact

def fact_mod(n, p, pk, fact):
	res = 1
	while n > 0:
		times = n // pk
		res = mulmod(res, power(fact[pk - 1], times, pk), pk)
		res = mulmod(res, fact[n % pk], pk)
		n //= p
	return res

def count_fact(n, p):
	ans = 0
	while n > 0:
		ans += n // p
		n //= p
	return ans

def ncr_pk(n, r, p, e):
	if r > n or r < 0:
		return 0
	if r == 0 or n == r:
		return 1
	_e = count_fact(n, p) - count_fact(r, p) - count_fact(n - r, p)
	assert _e >= 0
	if _e >= e:
		return 0
	pk = expo(p, e)
	fact = init(p, pk)
	ans = fact_mod(n, p, pk, fact)
	ans = mulmod(ans, mod_inverse(fact_mod(r, p, pk, fact), pk), pk)
	ans = mulmod(ans, mod_inverse(fact_mod(n - r, p, pk, fact), pk), pk)
	ans = mulmod(ans, expo(p, _e), pk)
	return ans

def pre_process(rem, mods):
	crt = []
	a = 1
	b = 1
	m = mods[0]
	crt.append([mods[0], a, b])
	L = len(mods)
	for i in range(1, L):
		a = mod_inverse(m, mods[i])
		b = mod_inverse(mods[i], m)
		crt.append([m, a, b])
		m *= mods[i]
	assert len(crt) == len(mods)
	return crt

def find_crt(rem, mods, crt):
	assert len(crt) == len(mods)
	ans = rem[0]
	m = crt[0][0]
	L = len(mods)
	for i in range(1, L):
		a = crt[i][1]
		b = crt[i][2]
		m = crt[i][0]
		_m = m * mods[i]
		ans = mulmod(ans, b * mods[i], _m)
		ans = (ans + mulmod(rem[i], a * m, _m)) % _m
	return ans

def ncr(n, r, m):
	pf = factorise(m)
	rem = []
	mods = []
	L = len(pf)
	for i in range(L):
		get = ncr_pk(n, r, pf[i][0], pf[i][1])
		rem.append(get)
		mods.append(expo(pf[i][0], pf[i][1]))
	crt = pre_process(rem, mods)
	ans = find_crt(rem, mods, crt)
	return ans

def add(a, b, c):
	res = a + b
	if res >= c:
		return res - c
	else:
		return res

def mod(a, b, c):
	res = a * b
	if res >= c:
		return res % c
	else:
		return res

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

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

def expo(a, b):
	(x, y) = (1, a)
	while b > 0:
		if b & 1:
			x = x * y
		y = y * y
		b >>= 1
	return x

def power(a, b, m):
	(x, y) = (1,)
	while b > 0:
		if b & 1:
			x = mod(x, y, m)
		y = mod(y, y, m)
		b >>= 1
	return x

def inv(a, m):
	return power(a, m - 2, m)

def mod_inverse(a, n):
	N = n
	xx = 0
	yy = 1
	y = 0
	x = 1
	while n > 0:
		q = a // n
		t = n
		n = a % n
		a = t
		t = xx
		xx = x - q * xx
		x = t
		t = yy
		yy = y - q * yy
		y = t
	x %= N
	x += N
	x %= N
	return x
import random
from queue import Queue

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

def expo(a, b):
	(x, y) = (1, a)
	while b > 0:
		if b & 1:
			x = x * y
		y = y * y
		b >>= 1
	return x
primes = [0] * 100000

def sieve():
	primes[1] = 1
	primes[2] = 2
	j = 4
	while j < 100000:
		primes[j] = 2
		j += 2
	j = 3
	while j < 100000:
		if primes[j] == 0:
			primes[j] = j
			i = j * j
			k = j << 1
			while i < 100000:
				primes[i] = j
				i += k
		j += 2

def rabin_miller(p):
	if p < 100000:
		return primes[p] == p
	if p % 2 == 0:
		return False
	s = p - 1
	while s % 2 == 0:
		s >>= 1
	for i in range(5):
		a = random.randrange(p - 1) + 1
		temp = s
		mod = pow(a, temp, p)
		while temp != p - 1 and mod != 1 and (mod != p - 1):
			mod = mod * mod % p
			temp = temp * 2
		if mod != p - 1 and temp % 2 == 0:
			return False
	return True

def brent(N):
	if N % 2 == 0:
		return 2
	if N < 100000:
		return primes[N]
	(y, c, m) = (random.randint(1, N - 1), random.randint(1, N - 1), random.randint(1, N - 1))
	(g, r, q) = (1, 1, 1)
	while g == 1:
		x = y
		for i in range(r):
			y = (y * y % N + c) % N
		k = 0
		while k < r and g == 1:
			ys = y
			for i in range(min(m, r - k)):
				y = (y * y % N + c) % N
				q = q * abs(x - y) % N
			g = gcd(q, N)
			k = k + m
		r = r * 2
	if g == N:
		while True:
			ys = (ys * ys % N + c) % N
			g = gcd(abs(x - ys), N)
			if g > 1:
				break
	return g

def factorise(n):
	Q_1 = Queue()
	Q_2 = []
	Q_1.put(n)
	while not Q_1.empty():
		l = Q_1.get()
		if rabin_miller(l):
			Q_2.append(l)
			continue
		d = brent(l)
		if d == l:
			Q_1.put(l)
		else:
			Q_1.put(d)
			Q_1.put(l // d)
	return Q_2

def sieve():
	t = int(input())
	for _ in range(t):
		n = int(input())
		L = factorise(n)
		L.sort()
		i = 0
		while i < len(L):
			cnt = L.count(L[i])
			(print('%s^%s' % (L[i], cnt)),)
			i += cnt
		print

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

def mod_inverse(a, n):
	N = n
	xx = 0
	yy = 1
	y = 0
	x = 1
	while n > 0:
		q = a // n
		t = n
		n = a % n
		a = t
		t = xx
		xx = x - q * xx
		x = t
		t = yy
		yy = y - q * yy
		y = t
	x %= N
	x += N
	x %= N
	return x
primes = [0] * 1000000

def sieve():
	primes[1] = 1
	primes[2] = 2
	j = 4
	while j < 1000000:
		primes[j] = 2
		j += 2
	j = 3
	while j < 1000000:
		if primes[j] == 0:
			primes[j] = j
			i = j * j
			k = j << 1
			while i < 1000000:
				primes[i] = j
				i += k
		j += 2
from random import *
import time

def ilog2(n):
	return 0 if n <= 0 else n.bit_length() - 1

def pack(pack, shamt):
	size = len(pack)
	while size > 1:
		npack = []
		for i in range(0, size - 1, 2):
			npack += [pack[i] | pack[i + 1] << shamt]
		if size & 1:
			npack += [pack[-1]]
		(pack, size, shamt) = (npack, size + 1 >> 1, shamt << 1)
	return pack[0]

def unpack(M, size, shamt):
	(s, sizes) = (size, [])
	while s > 1:
		sizes += [s]
		s = s + 1 >> 1
	ret = [M]
	for size in sizes[::-1]:
		(mask, nret) = ((1 << shamt) - 1, [])
		for c in ret:
			nret += [c & mask, c >> shamt]
		(ret, shamt) = (nret[:size], shamt >> 1)
	return ret

def poly_mul(f, g, mod=1000000007):
	size = min(len(f), len(g))
	shift = ((mod - 1) ** 2 * size).bit_length()
	rsize = len(f) + len(g) - 1
	h = unpack(pack(f, shift) * pack(g, shift), rsize, shift * (1 << ilog2(rsize - 1)))
	return [int(x % mod) for x in h]
s = input()
try:
	b = s.index('[')
	e = s.rindex(']')
	cb = s[b:e].index(':')
	ce = s[b:e].rindex(':')
	if b > e or cb == ce:
		raise ValueError
	res = 4 + s[b + cb:b + ce].count('|')
	print(res)
except ValueError:
	print(-1)


def main():
	s = input()
	(left, right) = (s.find('['), s.rfind(']'))
	if left < 0 or right < 0 or left >= right:
		print(-1)
		return
	s = s[left + 1:right]
	(left, right) = (s.find(':'), s.rfind(':'))
	if left < 0 or right < 0 or left >= right:
		print(-1)
		return
	s = s[left + 1:right]
	print(4 + s.count('|'))
main()


import sys
s = input()
n = len(s)
if '[' not in s:
	print(-1)
	sys.exit()
ind = s.index('[')
if ':' not in s[ind:]:
	print(-1)
	sys.exit()
ind1 = s[ind:].index(':') + ind
s = s[::-1]
if ']' not in s:
	print(-1)
	sys.exit()
ind2 = s.index(']')
if ':' not in s[ind2:]:
	print(-1)
	sys.exit()
ind3 = s[ind2:].index(':') + ind2
ind2 = n - 1 - ind2
ind3 = n - 1 - ind3
s = s[::-1]
if ind < ind1 < ind3 < ind2:
	print(4 + s[ind1 + 1:ind3].count('|'))
else:
	print(-1)


def number(l):
	if l.count('[') == 0 or l.count(']') == 0:
		return -1
	n = l.index('[')
	l1 = l[::-1]
	n1 = len(l) - l1.index(']')
	if n1 < n:
		return -1
	l1 = l[n:n1]
	if l1.count(':') < 2:
		return -1
	n = l1.index(':')
	l2 = l1[::-1]
	n1 = len(l1) - l2.index(':')
	l2 = l1[n:n1]
	return 4 + l2.count('|')
s = input()
l = list(s)
print(number(l))


string = input()
n = len(string)
possible = True
firstOB = 0
while string[firstOB] != '[':
	firstOB += 1
	if firstOB == n:
		possible = False
		break
if not possible:
	print(-1)
	exit()
firstOC = firstOB
while string[firstOC] != ':':
	firstOC += 1
	if firstOC == n:
		possible = False
		break
if not possible:
	print(-1)
	exit()
lastCB = n - 1
while string[lastCB] != ']':
	lastCB -= 1
	if lastCB == 0:
		possible = False
		break
if not possible:
	print(-1)
	exit()
lastCC = lastCB
while string[lastCC] != ':':
	lastCC -= 1
	if lastCC == 0:
		possible = False
		break
if not possible:
	print(-1)
	exit()
if firstOC < lastCC:
	cnt = 0
	for i in range(firstOC + 1, lastCC):
		if string[i] == '|':
			cnt += 1
	print(4 + cnt)
else:
	print(-1)


import math

def get_bayan_length(s):
	left_offset = 0
	for i in range(len(s)):
		left_offset += 1
		if s[i] == '[':
			break
	for i in range(left_offset, len(s)):
		left_offset += 1
		if s[i] == ':':
			break
	if len(s) - left_offset < 2:
		return -1
	right_offset = 0
	for i in range(len(s) - 1, -1, -1):
		right_offset += 1
		if s[i] == ']':
			break
	for i in range(len(s) - 1 - right_offset, -1, -1):
		right_offset += 1
		if s[i] == ':':
			break
	if len(s) - left_offset - right_offset < 0:
		return -1
	return 4 + s[left_offset:len(s) - right_offset].count('|')
s = input()
print(get_bayan_length(s))


s = input()
n = len(s)
ind = -1
f = False
for i in range(n):
	if s[i] == '[':
		f = True
	elif s[i] == ':':
		if f:
			ind = i
			break
bind = -1
f = False
for i in range(n - 1, -1, -1):
	if s[i] == ']':
		f = True
	elif s[i] == ':':
		if f:
			bind = i
			break
if ind == -1 or bind == -1:
	print(-1)
elif ind >= bind:
	print(-1)
else:
	ans = 4
	for i in range(ind + 1, bind):
		if s[i] == '|':
			ans += 1
	print(ans)


s = input()
i = 0
flag = 0
for i in range(0, len(s)):
	if s[i] == '[' and flag == 0:
		flag = 1
	elif s[i] == ':' and flag == 1:
		flag = 2
		break
l = len(s)
if l < 4 or i > l - 3:
	print(-1)
elif flag == 2:
	j = l - 1
	while j > i:
		if s[j] == ']' and flag == 2:
			flag = 3
		elif s[j] == ':' and flag == 3:
			flag = 4
			break
		j -= 1
	if flag != 4:
		print(-1)
	else:
		count = 4
		for k in range(i, j):
			if s[k] == '|':
				count += 1
		print(count)
else:
	print(-1)


import sys

def run(s, q):
	c = s.find(q)
	if c == -1:
		print(-1)
		sys.exit()
	return s[c + 1:]
s = str(input())
s = run(run(s, '['), ':')
s = s[::-1]
s = run(run(s, ']'), ':')
print(s.count('|') + 4)


def main(s):
	res = -1
	if '[' in s:
		a = s.index('[')
		if ']' in s[a:]:
			b = s[a:].rfind(']') + a
			if ':' in s[a:b]:
				c = s[a:b].index(':') + a + 1
				if ':' in s[c:b]:
					d = s[c:b].rfind(':') + c
					res = 4 + s[c:d].count('|')
	return res
print(main(input()))


from collections import deque

def pop_until(queue, stopleft, stopright):
	while queue and s[0] != stopleft:
		s.popleft()
	while queue and s[-1] != stopright:
		s.pop()
s = deque(input())
pop_until(s, '[', ']')
if not (s and s[0] == '[' and (s[-1] == ']')):
	print(-1)
	exit(0)
s.popleft()
s.pop()
pop_until(s, ':', ':')
if not len(s) >= 2:
	print(-1)
	exit(0)
s.popleft()
s.pop()
vertical_lines = s.count('|')
print(vertical_lines + 4)


s = input()
open = s.find('[')
close = s.rfind(']')
fc = s.find(':', open)
lc = s.rfind(':', 0, close)
if open != -1 and close != -1 and (fc != lc) and (fc != -1) and (lc != -1) and (open < fc < lc < close):
	print(s[fc + 1:lc].count('|') + 4)
else:
	print(-1)


s = input()
if not '[' in s or not ']' in s:
	print(-1)
else:
	a = s.index('[')
	b = len(s) - s[::-1].index(']') - 1
	s = s[a:b + 1]
	if s.count(':') < 2:
		print(-1)
	else:
		a = s.index(':')
		b = len(s) - s[::-1].index(':') - 1
		s = s[a:b + 1]
		print(s.count('|') + 4)


s = input()
n = len(s)
a = 0
for i in range(n):
	if s[i] == '[' and a == 0:
		a = 1
	if a == 1 and s[i] == ':':
		a = 2
		s = s[i + 1:]
		break
s = s[::-1]
b = 0
for i in range(len(s)):
	if s[i] == ']' and b == 0:
		b = 1
	if b == 1 and s[i] == ':':
		b = 2
		s = s[i + 1:]
		break
if a < 2 or b < 2:
	print('-1')
else:
	print(4 + s.count('|'))


a = list(input())
n = len(a)
leftbraki = -1
rightbraki = -1
for i in range(n - 1):
	if a[i] == '[':
		leftbraki = i
		break
for i in range(n - 1, -1, -1):
	if a[i] == ']':
		rightbraki = i
		break
leftco = -1
rightco = -1
for i in range(leftbraki + 1, n, 1):
	if a[i] == ':':
		leftco = i
		break
for i in range(rightbraki - 1, -1, -1):
	if a[i] == ':':
		rightco = i
		break
remo = 0
danda = 0
colo = 0
for i in range(leftco + 1, rightco, 1):
	if a[i] == '|':
		danda += 1
	if a[i] == ':':
		colo += 1
if leftbraki < leftco and leftco < rightco and (rightco < rightbraki):
	if leftbraki >= 0 and leftco >= 1 and (rightco >= 2) and (rightbraki >= 3):
		print(4 + danda)
	else:
		print('-1')
else:
	print('-1')


s = input()
c = []
l = -1
r = -1
for i in range(len(s)):
	if s[i] == '[':
		l = i
		break
for i in reversed(range(len(s))):
	if s[i] == ']':
		r = i
		break
if l == -1 or r == -1:
	print(-1)
else:
	p = -1
	for i in range(l, r):
		if s[i] == ':':
			p = i
			break
	q = -1
	for i in reversed(range(p, r)):
		if s[i] == ':':
			q = i
			break
	if p == -1 or q == -1 or p == q:
		print(-1)
	else:
		y = 0
		for i in range(p, q):
			if s[i] == '|':
				y += 1
		print(4 + y)


from sys import stdin
string = stdin.readline()
length = len(string)
if '[' not in string or ']' not in string or string.count(':') < 2:
	print(-1)
else:
	lb = lc = rb = rc = -1
	lb = string.index('[')
	for i in range(lb + 1, length):
		if string[i] == ':':
			lc = i
			break
	for i in range(length - 1, -1, -1):
		if string[i] == ']':
			rb = i
			break
	for i in range(rb - 1, -1, -1):
		if string[i] == ':':
			rc = i
			break
	if lb < lc < rc and rc < rb:
		cnt = 4
		for i in range(lc + 1, rc):
			if string[i] == '|':
				cnt += 1
		print(cnt)
	else:
		print(-1)


s = input()
n = len(s)
open_b = -1
close_b = -1
open_d = -1
close_d = -1
for i in range(n):
	if s[i] == '[':
		open_b = i
		break
for i in range(n):
	if s[i] == ']':
		close_b = i
if open_b == -1 or close_b == -1:
	print(-1)
	exit()
for i in range(open_b, close_b + 1):
	if s[i] == ':':
		open_d = i
		break
if open_d == -1:
	print(-1)
	exit()
for i in range(open_d + 1, close_b + 1):
	if s[i] == ':':
		close_d = i
if close_d == -1 or open_d == close_d:
	print(-1)
	exit()
k = 0
for i in range(open_d, close_d + 1):
	if s[i] == '|':
		k += 1
print(4 + k)


s = input()
i = s.find('[')
if i == -1:
	print(-1)
	exit()
s = s[i:]
i = s.rfind(']')
if i == -1:
	print(-1)
	exit()
s = s[:i + 1]
(l, h) = (0, 0)
for (i, d) in enumerate(s):
	if d == ':':
		l = i
		break
for (i, d) in enumerate(s):
	if d == ':':
		h = i
if l == h:
	print(-1)
	exit()
c = 0
for i in range(l + 1, h):
	if s[i] == '|':
		c += 1
print(c + 4)


s = str(input())
found_opening = False
slash_is = []
body_is = []
found_closing = False
for i in range(len(s)):
	if s[i] == '[' and (not found_opening):
		found_opening = True
		opening_i = i
	if s[i] == ':' and found_opening:
		slash_is.append(i)
	if s[i] == ']' and found_opening:
		found_closing = True
		closing_i = i
if found_opening and found_closing and (len(slash_is) >= 2):
	slash_end = -1
	for i in slash_is:
		if i < closing_i:
			slash_end = i
	slash_start = min(slash_is)
	for i in range(len(s)):
		if s[i] == '|' and slash_start < i < slash_end:
			body_is.append(i)
	if slash_end == -1 or slash_end == slash_start:
		print(-1)
	else:
		print(len(body_is) + 4)
else:
	print(-1)


s = input()
opt = -1
lidx = s.find('[')
ridx = s.rfind(']')
if lidx != -1 and ridx > lidx:
	s = s[lidx + 1:ridx]
	lidx = s.find(':')
	ridx = s.rfind(':')
	if lidx != -1 and ridx > lidx:
		opt = 4
		s = s[lidx + 1:ridx]
		opt += len(list(filter(lambda x: x == '|', s)))
print(opt)


s = input()
tf1 = False
for i in range(len(s)):
	if s[i] == '[':
		tf1 = True
		break
tf2 = False
for j in range(len(s) - 1, -1, -1):
	if s[j] == ']':
		tf2 = True
		break
if tf1 and tf2 and (i < j):
	tf1 = False
	for x in range(i + 1, j):
		if s[x] == ':':
			tf1 = True
			break
	if tf1:
		tf1 = False
		for y in range(j - 1, i, -1):
			if s[y] == ':':
				if y > x:
					tf1 = True
				break
		if tf1:
			c = 0
			for z in range(x + 1, y):
				if s[z] == '|':
					c += 1
			print(4 + c)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


acc = input()
bS = -1
bE = -1
cS = -1
cE = -1
for i in range(0, len(acc)):
	if acc[i] == '[':
		bS = i
		break
temp1 = len(acc) - 1
while temp1 > bS:
	if acc[temp1] == ']':
		bE = temp1
		break
	else:
		temp1 = temp1 - 1
if bS == -1 or bE == -1:
	print('-1')
	exit()
for i in range(bS + 1, bE):
	if acc[i] == ':':
		cS = i
		break
temp1 = bE - 1
while temp1 > cS:
	if acc[temp1] == ':':
		cE = temp1
		break
	else:
		temp1 = temp1 - 1
if cS == -1 or cE == -1:
	print('-1')
	exit()
temp = 4
for i in range(cS, cE):
	if acc[i] == '|':
		temp += 1
print(temp)


left_accordion_stack = ['[', ':']
right_accordion_stack = [']', ':']

def accordion(s):
	accordion_len = 4
	l_pointer = 0
	while l_pointer < len(s) and left_accordion_stack:
		if s[l_pointer] == left_accordion_stack[0]:
			left_accordion_stack.pop(0)
		l_pointer += 1
	r_pointer = len(s) - 1
	while r_pointer > l_pointer - 1 and right_accordion_stack:
		if s[r_pointer] == right_accordion_stack[0]:
			right_accordion_stack.pop(0)
		r_pointer -= 1
	if not right_accordion_stack and (not left_accordion_stack):
		for i in range(l_pointer, r_pointer + 1):
			if s[i] == '|':
				accordion_len += 1
		return accordion_len
	else:
		return -1
s = input()
print(accordion(s))


def main():
	s = input()
	s = list(s)
	l = 0
	i = 0
	pair = False
	while i < len(s) and s[i] != '[':
		i += 1
	i += 1
	while i < len(s) and s[i] != ':':
		i += 1
	j = len(s) - 1
	while j > i and s[j] != ']':
		j -= 1
	j -= 1
	while j > i and s[j] != ':':
		j -= 1
	for k in range(i, j):
		if s[k] == '|':
			l += 1
	if j <= i:
		print(-1)
	else:
		print(l + 4)
main()


s = input()
n = len(s)
a = 0
na = 0
b = 0
nb = 0
c = 0
d = 0
e = 0
for i in range(n):
	if s[i] == '[':
		na = 1
		a = i
		break
for i in range(n):
	if s[i] == ']':
		b = i
for i in range(a, b):
	if s[i] == ':':
		c = i
		break
for i in range(a, b):
	if s[i] == ':':
		d = i
if a > b:
	print(-1)
elif c == 0 or d == 0 or na == 0:
	print(-1)
elif c == d:
	print(-1)
else:
	for i in range(c, d):
		if s[i] == '|':
			e += 1
	print(4 + e)


accords = input()
lft = accords.find('[')
rt = accords.rfind(']')
if lft < rt and lft != -1 and (rt != -1):
	piano = accords[lft:rt + 1]
	lft = piano.find(':')
	rt = piano.rfind(':')
	if lft != -1 and lft != rt:
		count = piano[lft:rt + 1].count('|')
		print(4 + count)
	else:
		print(-1)
else:
	print(-1)


import sys
inf = float('inf')
mod = 1000000007

def get_array():
	return list(map(int, sys.stdin.readline().split()))

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

def input():
	return sys.stdin.readline()

def main():
	s = input().strip()
	n = len(s)
	flag = 0
	(mx, curr) = (0, 0)
	stack = []
	(opening, closing) = (-1, -1)
	for i in range(n):
		if s[i] == '[':
			opening = i
			break
	for i in range(n - 1, -1, -1):
		if s[i] == ']':
			closing = i
			break
	if opening == -1 or closing == -1:
		print(-1)
		return
	(c_opening, c_closing) = (-1, -1)
	for i in range(opening + 1, closing):
		if s[i] == ':':
			c_opening = i
			break
	for i in range(closing, opening, -1):
		if s[i] == ':':
			c_closing = i
			break
	if c_opening == -1:
		print(-1)
		return
	if closing <= opening:
		print(-1)
		return
	if c_opening == c_closing:
		print(-1)
		return
	check = False
	for i in range(c_opening + 1, c_closing):
		if s[i] == '|':
			mx += 1
	print(mx + 4)
main()


from collections import deque
s = deque(input())
while s and s[0] != '[':
	s.popleft()
while s and s[-1] != ']':
	s.pop()
if not (s and s[0] == '[' and (s[-1] == ']')):
	print(-1)
	exit(0)
s.popleft()
s.pop()
while s and s[0] != ':':
	s.popleft()
while s and s[-1] != ':':
	s.pop()
if not len(s) >= 2:
	print(-1)
	exit(0)
s.popleft()
s.pop()
vertical_lines = sum([1 for c in s if c == '|'])
print(vertical_lines + 4)


s = input()
p = len(s)
first = -1
last = -1
ans = 0
for i in range(0, p):
	if s[i] == '[':
		first = i
		break
for i in range(0, p):
	if s[p - 1 - i] == ']':
		last = p - 1 - i
		break
w = []
t = 0
if first == -1 or last == -1 or first >= last:
	ans = -1
else:
	for i in range(first, last):
		if s[i] == ':':
			w.append(i)
	if len(w) < 2:
		ans = -1
	else:
		for i in range(w[0], w[-1]):
			if s[i] == '|':
				t = t + 1
		ans = t + 4
print(ans)


s = input()
curr = ''

def check_first(inp, symb):
	count_curr = 0
	for i in range(len(inp)):
		if inp[i] == symb:
			return (True, inp[i + 1:], count_curr)
		else:
			count_curr += 1
	return (False, None, None)

def final_check(s_):
	count = 0
	curr = check_first(s_, '[')
	if curr[0] == False or len(curr[1]) == 0:
		return -1
	else:
		count += curr[2]
		curr = check_first(curr[1], ':')
		if curr[0] == False or len(curr[1]) == 0:
			return -1
		else:
			count += curr[2]
			new_tmp = curr[1][::-1]
			curr = check_first(new_tmp, ']')
			if curr[0] == False or len(curr[1]) == 0:
				return -1
			else:
				count += curr[2]
				curr = check_first(curr[1], ':')
				if curr[0] == False:
					return -1
				else:
					count += curr[2]
					tmp = curr[1]
					for i in range(len(tmp)):
						if tmp[i] != '|':
							count += 1
					return count
if final_check(s) == -1:
	print(-1)
else:
	print(len(s) - final_check(s))


import string
s = list(input())
l = ''
count = 0
for i in range(len(s)):
	if s[i] == '[' or s[i] == '|' or s[i] == ':' or (s[i] == ']'):
		l += s[i]
i = l.find('[')
j = l.rfind(']')
if i != -1 and j != -1:
	count += 2
	temp = l[i:j + 1]
	if temp.count(':') >= 2:
		a = temp.find(':')
		b = temp.rfind(':')
		if a != -1 and b != -1:
			count += 2
			temp2 = temp[a:b + 1]
			c = temp2.count('|')
			count += c
		else:
			count = -1
	else:
		count = -1
else:
	count = -1
print(count)


s = [i for i in input()]
l = len(s)
(i, j) = (0, l - 1)
while i < l:
	if s[i] == '[':
		break
	i += 1
while i < l:
	if s[i] == ':':
		break
	i += 1
while j >= 0:
	if s[j] == ']':
		break
	j -= 1
while j >= 0:
	if s[j] == ':':
		break
	j -= 1
if i >= j:
	print(-1)
else:
	c = 0
	for i in range(i, j + 1):
		if s[i] == '|':
			c += 1
	print(c + 4)


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())

def solve():
	s = input()
	n = len(s)
	i = 0
	while i < n:
		if s[i] == '[':
			break
		i += 1
	if i == n:
		print(-1)
		return
	j = n - 1
	while j >= 0:
		if s[j] == ']':
			break
		j -= 1
	if i >= j:
		print(-1)
		return
	ans = 2
	while i < j:
		if s[i] == ':':
			ans += 1
			break
		i += 1
	if i >= j:
		print(-1)
		return
	while j > i:
		if s[j] == ':':
			ans += 1
			break
		j -= 1
	if i >= j:
		print(-1)
		return
	for k in range(i, j):
		if s[k] == '|':
			ans += 1
	print(ans)
t = 1
while t:
	t -= 1
	solve()


s = input().strip()
s = ''.join(filter(lambda x: x in ['[', '|', ']', ':'], s))

def failed():
	print(-1)
	exit(0)
i1 = s.find('[')
if i1 == -1:
	failed()
s = s[i1:]
i1 = 0
i2 = s.find(':')
if i2 != -1:
	s = '[' + s[i2:]
else:
	failed()
s = s[::-1]
i1 = s.find(']')
if i1 == -1:
	failed()
s = s[i1:]
i2 = s.find(':')
if i2 != -1:
	s = ']' + s[i2:]
else:
	failed()
if len(s) < 4:
	failed()
s = ''.join(filter(lambda x: x in ['|'], s[2:-2]))
s = '[:' + s + ':]'
print(len(s))


s = input()
fs = s.find('[')
fv = s.find(':', fs, -1)
ls = s.rfind(']')
lv = s.rfind(':', 0, ls)
if fv != -1 and lv != -1 and (fs != -1) and (ls != -1) and (fv < lv):
	print(s[fv:lv].count('|') + 4)
else:
	print(-1)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	S = listStr()
	L = len(S)
	ans = 0
	while S and S[-1] != ']':
		ans += 1
		S.pop()
	if not S:
		return -1
	S.pop()
	while S and S[-1] != ':':
		ans += 1
		S.pop()
	if not S:
		return -1
	S.pop()
	S.reverse()
	while S and S[-1] != '[':
		ans += 1
		S.pop()
	if not S:
		return -1
	S.pop()
	while S and S[-1] != ':':
		ans += 1
		S.pop()
	if not S:
		return -1
	S.pop()
	for a in S:
		if a != '|':
			ans += 1
	return L - ans
print(solve())


s = input()
ans = []
start = -1
for i in range(len(s)):
	if s[i] == '[':
		start = i
		ans.append('[')
		break
if start == -1:
	print('-1')
else:
	sc = -1
	for i in range(start, len(s)):
		if s[i] == ':':
			sc = i
			ans.append(':')
			break
	if sc == -1:
		print('-1')
	else:
		cb = -1
		for i in range(len(s) - 1, sc, -1):
			if s[i] == ']':
				cb = i
				ans.append(']')
				break
		if cb == -1:
			print(-1)
		else:
			cc = -1
			for i in range(cb, sc, -1):
				if s[i] == ':':
					cc = i
					ans.append(':')
					break
			if cc == -1:
				print('-1')
			else:
				v = 0
				for i in range(sc, cc):
					if s[i] == '|':
						ans.append('|')
						v += 1
				print(len(ans))


import sys
import bisect
t = 1
mod = 10 ** 9 + 7
for _ in range(t):
	s = input()
	l = []
	l.append(-1)
	for i in range(len(s)):
		if s[i] == '[':
			l.append(i)
			break
	for i in range(l[-1] + 1, len(s)):
		if s[i] == ':':
			l.append(i)
			break
	l1 = []
	l1.append(len(s))
	for i in range(len(s) - 1, -1, -1):
		if s[i] == ']':
			l1.append(i)
			break
	for i in range(l1[-1] - 1, -1, -1):
		if s[i] == ':':
			l1.append(i)
			break
	if len(l1) == 3 and len(l) == 3:
		if l[-1] < l1[-1]:
			cnt = 0
			for i in range(l[-1], l1[-1]):
				if s[i] == '|':
					cnt += 1
			print(4 + cnt)
		else:
			print(-1)
	else:
		print(-1)


s = list(input())
firstopen = len(s) + 1
firstcolon = len(s) + 1
lastclose = -1
lastcolon = -1
for i in range(len(s)):
	if s[i] == '[':
		firstopen = i
		break
for i in range(len(s)):
	if s[i] == ']':
		lastclose = i
for i in range(firstopen, lastclose + 1):
	if s[i] == ':':
		firstcolon = i
		break
for i in range(firstopen, lastclose + 1):
	if s[i] == ':':
		lastcolon = i
if firstopen < lastclose and firstcolon < lastcolon:
	goodcount = 0
	for i in range(firstcolon, lastcolon + 1):
		if s[i] == '|':
			goodcount += 1
	print(goodcount + 4)
else:
	print(-1)


import sys
s = input()
n = len(s)
ans = ''
(p1, p2, p3, p4) = (None, None, None, None)
for i in range(n):
	if s[i] == '[' and p1 is None:
		p1 = i
	if s[i] == ':' and p1 is not None and (p2 is None):
		p2 = i
for i in range(n - 1, -1, -1):
	if s[i] == ']' and p4 is None:
		p4 = i
	if s[i] == ':' and p4 is not None and (p3 is None):
		p3 = i
if p2 is None or p3 is None or p2 >= p3:
	print(-1)
	sys.exit(0)
ans = 4
for i in range(p2, p3):
	if s[i] == '|':
		ans += 1
print(ans)


l = list(input())
a = []
b = []
c = []
le = len(l)
t1 = 0
t2 = 0
t = 0
for i in range(le):
	if l[i] == '[':
		a += [i]
		t = 1
	elif l[i] == ']':
		b += [i]
		t1 = 1
a = a + [le - 1]
b = b + [0]
a1 = min(a)
a2 = max(b)
c1 = 0
if a1 < a2:
	for i in range(a1 + 1, a2):
		if l[i] == ':':
			c1 += 1
			c += [i]
	if c1 > 1:
		d = 0
		for i in range(min(c) + 1, max(c)):
			if l[i] == '|':
				d += 1
		print(d + 4)
	else:
		print('-1')
else:
	print('-1')


line = input()
o = line.find('[')
if o == -1:
	print(-1)
	exit(0)
c1 = line.find(':', o + 1)
if c1 == -1:
	print(-1)
	exit(0)
c = line.rfind(']', c1)
if c == -1:
	print(-1)
	exit(0)
c2 = line.rfind(':', c1 + 1, c)
if c2 == -1:
	print(-1)
	exit(0)
v = line.count('|', c1 + 1, c2)
print(v + 4)


s = input()
l = len(s)
f1 = s.find('[')
l1 = s.rfind(']')
f2 = s.find(':')
l2 = s.rfind(':')
s = s[f1:l1 + 1]
f1 = s.find('[')
l1 = s.rfind(']')
f2 = s.find(':')
l2 = s.rfind(':')
r = s[f2:l2 + 1]
n = ''
for i in r:
	if i == '|':
		n += i
if f1 < f2 and f2 < l2 and (l2 < l1):
	print(4 + len(n))
else:
	print(-1)


ind = [-1] * 4
need = 1
arr = input()
n = len(arr)
for i in range(n):
	if need == 1:
		if arr[i] == '[':
			ind[0] = i
			need += 1
	elif need == 2:
		if arr[i] == ':':
			ind[1] = i
			break
need = 4
for i in range(n - 1, -1, -1):
	if need == 4:
		if arr[i] == ']':
			ind[3] = i
			need -= 1
	elif need == 3:
		if arr[i] == ':':
			ind[2] = i
			break
if ind[1] == ind[2] or ind != sorted(ind):
	print(-1)
	exit()
for i in range(4):
	if ind[i] == -1:
		print(-1)
		exit()
res = 4 + (ind[2] - 1 - ind[1])
for i in range(ind[1] + 1, ind[2]):
	if arr[i] != '|':
		res -= 1
print(res)


def max_bayan_len(s):
	left_bracket_pos = s.find('[')
	if left_bracket_pos == -1:
		return -1
	left_colon_pos = s[left_bracket_pos:].find(':')
	if left_colon_pos == -1:
		return -1
	left_colon_pos = left_bracket_pos + left_colon_pos
	rev = s[::-1]
	tmp1 = rev.find(']')
	right_bracket_pos = len(s) - tmp1 - 1
	if tmp1 == -1 or right_bracket_pos < left_bracket_pos:
		return -1
	tmp2 = rev[tmp1:].find(':')
	right_colon_pos = right_bracket_pos - tmp2
	if tmp2 == -1 or right_colon_pos <= left_colon_pos:
		return -1
	add = s[left_colon_pos:right_colon_pos].count('|')
	return 4 + add
s = input()
print(max_bayan_len(s))


A = input()
found = 0
first = 0
for i in range(len(A)):
	if A[i] == '[':
		found = found + 1
		first = i
		break
for i in range(first + 1, len(A), 1):
	if A[i] == ':':
		found = found + 1
		first = i + 1
		break
last = 0
for i in range(len(A) - 1, first - 1, -1):
	if A[i] == ']':
		found = found + 1
		last = i
		break
for i in range(last - 1, first - 1, -1):
	if A[i] == ':':
		found = found + 1
		last = i
		break
bar = 0
for i in range(first, last, 1):
	if A[i] == '|':
		bar = bar + 1
if found != 4:
	print(-1)
else:
	print(bar + 4)


rpos = -1
flag = 0
res = 0
tmp = 0
s = input()
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']':
		rpos = i
		break
if rpos > 0:
	for i in range(rpos):
		if flag == 0:
			if s[i] == '[':
				flag = 1
		elif flag == 1:
			if s[i] == ':':
				flag = 2
		elif flag >= 2:
			if s[i] == ':':
				flag = 3
				res = tmp
			elif s[i] == '|':
				tmp += 1
	if flag == 3:
		print(res + 4)
	else:
		print(-1)
else:
	print(-1)


s = input()
flag = False
ind = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']':
		flag = True
		ind = i
		break
if flag:
	flag = False
	for i in range(ind - 1, -1, -1):
		if s[i] == ':':
			flag = True
			ind = i
			break
	if flag:
		flag = False
		for i in range(ind):
			if s[i] == '[':
				flag = True
				ind2 = i
				break
		if flag:
			flag = False
			for i in range(ind2 + 1, ind):
				if s[i] == ':':
					flag = True
					ind2 = i
					break
			t = 4
			if flag:
				for i in range(ind2 + 1, ind):
					if s[i] == '|':
						t += 1
				print(t)
			else:
				print(-1)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


strn = input()
rev = ''.join(reversed(strn))
n = len(strn)
count = -1
if '[' in strn:
	if ']' in strn:
		if strn.index('[') < n - 1 - rev.index(']'):
			strn = strn[strn.index('[') + 1:n - 1 - rev.index(']')]
			n = len(strn)
			count = 2
			rev = ''.join(reversed(strn))
			if ':' in strn:
				if strn.index(':') != n - 1 - rev.index(':'):
					count += 2
					strn = strn[strn.index(':') + 1:n - 1 - rev.index(':')]
					for x in strn:
						if x == '|':
							count += 1
				else:
					count = -1
			else:
				count = -1
print(count)


def sol():
	data = list(input())
	l = len(data)
	fBracket = -1
	lBracket = -1
	for i in range(l):
		if fBracket == -1 and data[i] == '[':
			fBracket = i
		elif fBracket != -1 and data[i] == ']':
			lBracket = i
	if fBracket == -1 or lBracket == -1:
		print(-1)
		return 0
	fDots = -1
	sLast = -1
	for i in range(fBracket + 1, lBracket):
		if data[i] == ':':
			if fDots == -1:
				fDots = i
			else:
				sLast = i
	if fDots == -1 or sLast == -1:
		print(-1)
		return 0
	c = 0
	for i in range(fDots + 1, sLast):
		if data[i] == '|':
			c += 1
	print(4 + c)
sol()


s = list(input())
(a, b, c, d) = (-1, -1, -1, -1)
for i in range(len(s)):
	if s[i] == '[' and a == -1:
		a = i
	elif s[i] == ']':
		b = i
if a == -1 or b == -1 or a > b:
	print(-1)
else:
	for i in range(a, b):
		if s[i] == ':' and c == -1:
			c = i
		elif s[i] == ':':
			d = i
	if c == -1 or d == -1 or c == d:
		print(-1)
	else:
		cnt = 0
		for i in range(c, d):
			if s[i] == '|':
				cnt += 1
		print(cnt + 4)


def optimize(s):
	sLen = len(s)
	left = 0
	right = sLen - 1
	while left < sLen:
		if s[left] != '[':
			left += 1
		else:
			break
	while right >= 0:
		if s[right] != ']':
			right -= 1
		else:
			break
	if left >= right:
		return -1
	while left < sLen:
		if s[left] != ':':
			left += 1
		else:
			break
	while right >= 0:
		if s[right] != ':':
			right -= 1
		else:
			break
	if left >= right:
		return -1
	count = 4
	for i in range(left + 1, right):
		if s[i] == '|':
			count += 1
	return count
s = input()
n = optimize(s)
print(str(n))


s = input()
open1 = False
open2 = False
close2 = False
close1 = False
start = -1
end = -1
ans = 0
x = 0
for j in range(len(s)):
	if open1 == False:
		if s[j] == '[':
			open1 = True
	elif open2 == False:
		if s[j] == ':':
			open2 = True
	else:
		start = j
		ans = ans + 2
		break
for j in reversed(range(len(s))):
	if close1 == False:
		if s[j] == ']':
			close1 = True
	elif close2 == False:
		if s[j] == ':':
			close2 = True
	else:
		end = j + 1
		ans = ans + 2
		break
if start > 0 and start <= end:
	for j in range(start - 1, end):
		if s[j] == '|':
			ans = ans + 1
	print(ans)
else:
	print(-1)


def f():
	q = input()
	s = ''
	for i in range(len(q)):
		if q[i] == '[' and s == '':
			s += q[i]
		elif s == '[' and q[i] == ':':
			s += q[i]
			i += 1
			break
	if s != '[:':
		return -1
	for k in range(-1, i - len(q) - 1, -1):
		if s == '[:' and q[k] == ']':
			s += q[k]
		elif s == '[:]' and q[k] == ':':
			s = '[::]'
			k -= 1
			break
	if s != '[::]':
		return -1
	c = 4
	for j in range(i, len(q) + k + 1):
		if q[j] == '|':
			c += 1
	return c
print(f())


s = input()
l = len(s)
bayan = 0
open = False
dv_first = False
dv_last = False
close = False
breaked = False
for i in range(l):
	a = s[i]
	if open == False:
		if a == '[':
			open = True
			bayan += 1
	elif dv_first == False:
		if a == ':':
			dv_first = True
			bayan += 1
			breaked = True
			break
if breaked == False:
	print(-1)
else:
	for j in range(l - 1, i, -1):
		a = s[j]
		if close == False:
			if a == ']':
				close = True
				bayan += 1
		elif dv_last == False:
			if a == ':':
				dv_last = True
				bayan += 1
		elif a == '|':
			bayan += 1
	if open and dv_first and dv_last and close:
		print(bayan)
	else:
		print(-1)


class CodeforcesTask1101BSolution:

	def __init__(self):
		self.result = ''
		self.accordion = ''

	def read_input(self):
		self.accordion = input()

	def process_task(self):
		starts = self.accordion.split('[', 1)
		if len(starts) > 1:
			acc = starts[1]
			stops = acc[::-1].split(']', 1)
			if len(stops) > 1:
				inside = stops[1]
				if inside.count(':') < 2:
					self.result = '-1'
				else:
					acc_s = len(inside.split(':', 1)[0])
					acc_e = len(inside[::-1].split(':', 1)[0])
					if not acc_e:
						acc_e = -len(inside)
					acc_p = inside[acc_s:-acc_e].count('|')
					self.result = str(4 + acc_p)
			else:
				self.result = '-1'
		else:
			self.result = '-1'

	def get_result(self):
		return self.result
Solution = CodeforcesTask1101BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


s = input()
f = 0
prya = -1
for i in range(len(s)):
	if f == 0 and s[i] == '[':
		f = 1
	elif f == 1 and s[i] == ':':
		prya = i
		break
prya2 = -1
f = 0
for i in range(len(s) - 1, -1, -1):
	if f == 0 and s[i] == ']':
		f = 1
	elif f == 1 and s[i] == ':':
		prya2 = i
		break
if prya == -1 or prya2 == -1 or prya2 <= prya:
	print(-1)
else:
	print(s[prya:prya2].count('|') + 4)


s = list(input())
if '[' not in s or ']' not in s:
	print(-1)
elif s.index('[') + 1 > len(s) - s[::-1].index(']'):
	print(-1)
else:
	k = 0
	while s[0] != '[':
		s.pop(0)
	s.reverse()
	while s[0] != ']':
		s.pop(0)
	if s.count(':') < 2:
		print(-1)
	else:
		while s[0] != ':':
			s.pop(0)
		s.reverse()
		while s[0] != ':':
			s.pop(0)
		print(s.count('|') + 4)


ins = input()
opn_brk = ins.find('[')
opn_cln = ins.find(':', opn_brk)
clo_brk = ins.rfind(']')
clo_cln = ins.rfind(':', opn_cln, clo_brk)
if opn_brk < opn_cln < clo_cln < clo_brk and opn_brk != -1 and (opn_cln != -1) and (clo_cln != -1):
	bar_cnt = ins[opn_cln + 1:clo_cln].count('|')
	print(bar_cnt + 4)
else:
	print(-1)


from sys import stdin
s = stdin.readline().strip()
x = -1
for i in range(len(s)):
	if s[i] == '[':
		x = i
		break
y = -1
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']':
		y = i
		break
if x == -1 or y == -1 or y < x:
	print(-1)
	exit(0)
x1 = -1
for i in range(x, y):
	if s[i] == ':':
		x1 = i
		break
y1 = -1
for i in range(y - 1, x, -1):
	if s[i] == ':':
		y1 = i
		break
if x1 == -1 or y1 == -1 or y1 <= x1:
	print(-1)
	exit(0)
ans = 4
for i in range(x1, y1):
	if s[i] == '|':
		ans += 1
print(ans)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return len(set(factors))

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
MOD = 10 ** 9 + 7
T = 1
for _ in range(T):
	s = str(stdin.readline().strip('\n'))
	(fb, lb) = (-1, -1)
	n = len(s)
	for i in range(n):
		if s[i] == '[':
			fb = i
			break
	for i in range(n):
		if s[n - i - 1] == ']':
			lb = n - i - 1
			break
	if fb > lb or fb == -1 or lb == -1:
		print(-1)
		continue
	fc = -1
	lc = -1
	for i in range(fb, lb + 1):
		if s[i] == ':':
			fc = i
			break
	for i in range(lb, fb - 1, -1):
		if s[i] == ':':
			lc = i
			break
	if fc == -1 or lc == -1 or fc == lc:
		print(-1)
		continue
	l = 0
	for i in range(fc, lc + 1):
		if s[i] == '|':
			l += 1
	print(2 + 2 + l)


a = input()
n = len(a)
ans = 0
cnt = 0
x = -1
for i in range(0, n):
	if str(a[i]) == '[':
		cnt = 1
	elif str(a[i]) == ':' and cnt == 1:
		cnt = 2
		x = i
		break
if x < 0:
	print(-1)
else:
	y = -1
	for i in range(n - 1, x, -1):
		if str(a[i]) == ']':
			cnt = 1
		elif str(a[i]) == ':' and cnt == 1:
			cnt = 2
			y = i
			break
	if y < 0:
		print(-1)
	else:
		ans = 4
		for i in range(x, y):
			if str(a[i]) == '|':
				ans += 1
		print(ans)


s = input()
try:
	i = s.index(':', s.index('['))
	r = s.count('|', i, s.rindex(':', i + 1, s.rindex(']', i))) + 4
except:
	r = -1
print(r)


import sys
s = sys.stdin.readline()
l = len(s)
answer = 0
i = 0
while i < l and s[i] != '[':
	i = i + 1
while i < l and s[i] != ':':
	i = i + 1
j = l - 1
while j > -1 and s[j] != ']':
	j = j - 1
while j > -1 and s[j] != ':':
	j = j - 1
if i == l or j == -1 or i >= j:
	print(-1)
else:
	for k in range(i + 1, j):
		if s[k] == '|':
			answer = answer + 1
	print(answer + 4)


s = input()
n = len(s)
l = 0
while l < n:
	if s[l] == '[':
		break
	l += 1
l2 = l + 1
while l2 < n:
	if s[l2] == ':':
		break
	l2 += 1
r = n - 1
while r > 0:
	if s[r] == ']':
		break
	r -= 1
r2 = r - 1
while r2 > 0:
	if s[r2] == ':':
		break
	r2 -= 1
if l2 >= r2:
	print(-1)
else:
	ans = 4
	for i in range(l2 + 1, r2):
		if s[i] == '|':
			ans += 1
	print(ans)


s = input()
s = s.rstrip()
n = len(s)
s = list(s)
(lb, rb, c1, c2, v, ct) = (0, 0, 0, 0, 0, 0)
if s.count('[') < 1 or s.count(':') < 2 or s.count(']') < 1:
	print(-1)
elif n < 4:
	print(-1)
else:
	ind = 0
	for i in range(0, n):
		if lb == 0:
			if s[i] == '[':
				lb = 1
			else:
				ct += 1
		elif lb == 1 and c1 == 0:
			if s[i] != ':':
				ct += 1
			elif s[i] == ':':
				c1 = 1
				ind = i
				break
	ind2 = n - 1
	for i in range(n - 1, ind, -1):
		if rb == 0:
			if s[i] == ']':
				rb = 1
			else:
				ct += 1
		elif rb == 1 and c2 == 0:
			if s[i] != ':':
				ct += 1
			elif s[i] == ':':
				c2 = 1
				ind2 = i
				break
	for i in range(ind + 1, ind2):
		if s[i] != '|':
			ct += 1
	if n - ct < 4:
		print(-1)
	else:
		print(n - ct)


from sys import *
from math import *
s = input()
b1 = -1
b2 = -1
c1 = -1
c2 = -1
f1 = f2 = f3 = f4 = 0
n = len(s)
for i in range(len(s)):
	if f1 == 0:
		if s[i] == '[':
			b1 = i
			f1 = 1
	if f1 == 1:
		if s[i] == ']':
			b2 = i
for i in range(b1, b2):
	if s[i] == ':' and f3 == 0:
		f3 = 1
		c1 = i
	if s[i] == ':' and f3 == 1:
		c2 = i
if c1 == c2 or b1 == -1 or b2 == -1 or (c1 == -1) or (c2 == -1):
	print(-1)
else:
	cnt = 4
	for i in range(c1, n):
		if s[i] == '|' and i > c1 and (i < c2):
			cnt += 1
	print(cnt)


import math
from decimal import *
import random
mod = int(1000000000.0) + 7
s = list(input())
n = len(s)
(p1, p2) = (-1, -1)
for i in range(n):
	if s[i] == '[' and p1 == -1:
		p1 = i
	if s[i] == ']':
		p2 = i + 1
if p1 < p2 - 1 and p1 != -1 and (p2 != -1) and (p2 - p1 - 2 >= 0):
	s = s[p1:p2]
	n = len(s)
	ans = int(n)
	(p1, p2) = (-1, -1)
	for i in range(n):
		if s[i] == ':' and p1 == -1:
			p1 = i
		if s[i] == ':':
			p2 = i + 1
	if p1 < p2 and p1 != -1 and (p2 != -1) and (p2 - p1 - 2 >= 0):
		s = s[p1:p2]
		n = len(s)
		ans -= ans - n
		cnt = 0
		for i in range(1, n - 1):
			if s[i] != '|':
				cnt += 1
		ans -= cnt
		print(ans + 2)
	else:
		print(-1)
else:
	print(-1)


import sys
s = input()
l = len(s)
s_list = [x for x in s]
counter = 0
try:
	a = s_list.index('[')
	counter += a
	s_list = s_list[a + 1:]
except:
	print(-1)
	sys.exit(0)
try:
	a = s_list.index(':')
	counter += a
	s_list = s_list[a + 1:]
except:
	print(-1)
	sys.exit(0)
s_list_rev = s_list.copy()
s_list_rev.reverse()
try:
	b = s_list_rev.index(']')
	counter += b
	s_list_rev = s_list_rev[b + 1:]
except:
	print(-1)
	sys.exit(0)
try:
	b = s_list_rev.index(':')
	counter += b
	s_list_rev = s_list_rev[b + 1:]
except:
	print(-1)
	sys.exit(0)
s_list_rev = [x for x in s_list_rev if x != '|']
counter += len(s_list_rev)
print(l - counter)


s = input()
n = len(s)
l1 = n
r1 = -1
l2 = n
r2 = -1
for i in range(n):
	if s[i] == '[':
		l1 = min(l1, i)
	if s[i] == ']':
		r1 = max(r1, i)
cnt = 0
for i in range(l1 + 1, r1):
	if s[i] == ':':
		l2 = min(l2, i)
		r2 = max(r2, i)
		cnt += 1
if l1 == n or r1 == -1 or cnt < 2:
	print(-1)
	exit()
ans = r2 - l2 + 3
for i in range(l2 + 1, r2):
	if s[i] != '|':
		ans -= 1
print(ans)


import sys
s = sys.stdin.readline()[:-1]
lb = s.find('[')
rb = s.rfind(']')
if lb == -1 or rb == -1 or lb >= rb:
	print(-1)
	sys.exit(0)
s = s[lb:rb + 1]
lb = s.find(':')
rb = s.rfind(':')
if lb == -1 or rb == -1 or lb >= rb:
	print(-1)
	sys.exit(0)
s = s[lb:rb + 1]
print(4 + s.count('|'))


import sys
a = input()
a = list(a)
h = []
f = []
s = 0
p = 0
b = a.copy()
flag1 = False
flag2 = False
for i in range(len(a)):
	if a[i] == '[':
		h.append(i)
		flag1 = True
	if a[i] == ']':
		s = i
		flag2 = True
if flag1 == False:
	print(-1)
	sys.exit()
if flag2 == False:
	print(-1)
	sys.exit()
h = h[0]
a = a[h + 1:s]
if a.count(':') < 2:
	print(-1)
	sys.exit()
for i in range(len(a)):
	if a[i] == ':':
		f.append(i)
a = a[f[0] + 1:f[-1]]
ans = 4 + a.count('|')
print(ans)


s = input()
count = 0
i = 0
flag = 0
for x in range(len(s)):
	if s[x] == '[':
		s = s[x + 1:]
		flag = 1
		break
if flag == 1:
	flag = 0
	for x in range(len(s)):
		if s[x] == ':':
			s = s[x + 1:]
			flag = 1
			break
	if flag == 1:
		flag = 0
		for x in range(len(s) - 1, -1, -1):
			if s[x] == ']':
				s = s[:x]
				flag = 1
				break
		if flag == 1:
			flag = 0
			for x in range(len(s) - 1, -1, -1):
				if s[x] == ':':
					s = s[:x]
					flag = 1
					break
			if flag == 1:
				for x in range(len(s)):
					if s[x] == '|':
						count += 1
			else:
				print(-1)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)
if flag == 1:
	print(count + 4)


s = input()
for c in range(len(s)):
	if s[c] == '[':
		break
if c == len(s) - 1:
	print('-1')
	exit(0)
else:
	s = s[c:]
for c in range(len(s) - 1, -1, -1):
	if s[c] == ']':
		break
if c == 0:
	print('-1')
	exit(0)
else:
	s = s[:c + 1]
count = 0
x = [c for c in range(len(s)) if s[c] == ':']
if len(x) < 2:
	print('-1')
	exit(0)
for c in range(x[0] + 1, x[-1]):
	if s[c] == '|':
		count += 1
print(count + 4)


s = input()
try:
	b = s.index('[')
	e = s.rindex(']')
	cb = s[b:e].index(':')
	ce = s[b:e].rindex(':')
	if b > e or cb == ce:
		raise ValueError
	res = 4 + s[b + cb:b + ce].count('|')
	print(res)
except ValueError:
	print(-1)


import sys

def main():
	s = input()
	if '[' in s and ']' in s:
		a = s.index('[') + 1
		b = len(s) - s[::-1].index(']') - 1
	else:
		print(-1)
		return 0
	s = s[a:b]
	if s.count(':') >= 2:
		a = s.index(':') + 1
		b = len(s) - s[::-1].index(':') - 1
	else:
		print(-1)
		return 0
	c = 0
	for i in s[a:b]:
		if i == '|':
			c += 1
	print(4 + c)
	return 0
main()


check = {'[': False, ':': [False, False], ']': False}
sequencia = []
accord = input()
ans = 0
iSeq = 0
l = 0
r = len(accord) - 1
while l < r:
	if accord[l] == '[':
		break
	l += 1
while r > l:
	if accord[r] == ']':
		break
	r -= 1
while l < r:
	if accord[l] == '[' and (not check['[']):
		sequencia.append('[')
		check['['] = True
		ans += 1
	elif accord[l] == ':' and (not check[':'][0]):
		sequencia.append(':')
		check[':'][0] = True
		ans += 1
	elif accord[l] == '|' and check[':'][0]:
		ans += 1
	if check[':'][1]:
		l += 1
	if accord[r] == ']' and (not check[']']):
		sequencia.append(']')
		check[']'] = True
		ans += 1
	elif accord[r] == ':' and (not check[':'][1]):
		sequencia.append(':')
		check[':'][1] = True
		ans += 1
	if not check[':'][1]:
		r -= 1
if ''.join(sequencia) == '[]::':
	print(ans)
else:
	print(-1)


s = input()
p1 = s.find('[')
p2 = s.find(':', p1)
p3 = s.rfind(']')
p4 = s.rfind(':', 0, p3)
if p1 < p2 < p4 < p3:
	print(4 + s[p2:p4].count('|'))
else:
	print(-1)


n = input()
t = 0
if n.count('[') < 1 or n.count(']') < 1:
	print(-1)
else:
	for i in range(len(n)):
		if n[i] == '[':
			c = i
			break
		t += 1
	for i in range(len(n) - 1, -1, -1):
		if n[i] == ']':
			d = i
			break
		t += 1
	s = n[c + 1:d]
	if s.count(':') < 2:
		print(-1)
	else:
		for i in range(len(s)):
			if s[i] == ':':
				c = i
				break
			t += 1
		for i in range(len(s) - 1, -1, -1):
			if s[i] == ':':
				d = i
				break
			t += 1
		s = s[c + 1:d]
		for i in s:
			if i != '|':
				t += 1
		print(len(n) - t)


import sys
string = input()
i = 0
while string[i] != '[':
	i += 1
	if i == len(string):
		print(-1)
		sys.exit(0)
OpeningBracket = i
ClosingBracket = 0
i += 1
while i < len(string):
	if string[i] == ']':
		ClosingBracket = i
	i += 1
if ClosingBracket == 0:
	print(-1)
	sys.exit(0)
i = OpeningBracket + 1
FirstColon = 0
SecondColon = 0
while i < ClosingBracket:
	if string[i] == ':' and FirstColon == 0:
		FirstColon = i
	elif string[i] == ':':
		SecondColon = i
	i += 1
if SecondColon == 0:
	print(-1)
	sys.exit(0)
i = FirstColon + 1
result = 0
while i < SecondColon:
	if string[i] == '|':
		result += 1
	i += 1
print(result + 4)


s = input()
if len(s) >= 4:
	s1 = -1
	s2 = -1
	s3 = -1
	s4 = -1
	for i in range(len(s)):
		if s1 < 0 and s[i] == '[':
			s1 = i
		if s1 >= 0 and s[i] == ':':
			s2 = i
			break
	if s2 > 0:
		for i in range(len(s) - 1, -1, -1):
			if s4 < 0 and i > s2 and (s[i] == ']'):
				s4 = i
			if s4 >= 0 and i > s2 and (s[i] == ':'):
				s3 = i
				break
	count = 0
	if s1 >= 0 and s2 >= 0 and (s3 >= 0) and (s4 >= 0):
		for i in range(s2 + 1, s3):
			if s[i] == '|':
				count += 1
		print(4 + count)
	else:
		print(-1)
else:
	print(-1)


def maxAccordionLength(s):
	if len(s) < 4:
		return -1
	openIndex = s.find('[')
	openHandle = s.find(':', openIndex)
	closeIndex = s.rfind(']', openHandle)
	closeHandle = s.rfind(':', openHandle, closeIndex)
	if not (openIndex < openHandle and openHandle < closeHandle and (closeHandle < closeIndex)):
		return -1
	if openIndex == -1 or openHandle == -1 or closeHandle == -1 or (closeIndex == -1):
		return -1
	return 4 + countBars(s, openHandle + 1, closeHandle)

def countBars(s, start, end):
	count = 0
	i = start
	while i < end:
		if s[i] == '|':
			count += 1
		i += 1
	return count

def __main__():
	print(maxAccordionLength(input('')))
__main__()


s = input()
n = len(s)
l = -1
f = 0
for i in range(n):
	if f == 0 and s[i] == '[':
		f = 1
	if f == 1 and s[i] == ':':
		f = 2
	if f == 2:
		l = i
		break
r = -1
f = 0
for i in range(n - 1, -1, -1):
	if f == 0 and s[i] == ']':
		f = 1
	if f == 1 and s[i] == ':':
		f = 2
	if f == 2:
		r = i
		break
if l > -1 and r > -1:
	if l < r:
		k = 0
		for i in s[l + 1:r]:
			if i == '|':
				k += 1
		print(4 + k)
	else:
		print(-1)
else:
	print(-1)


s = input()
if s.count('[') == 0 or s.count(']') == 0:
	print(-1)
	exit()
t = s[s.find('['):s.rfind(']') + 1]
if t.count(':') < 2:
	print(-1)
	exit()
t = t[t.find(':'):t.rfind(':') + 1]
print(4 + t.count('|'))


s = input()
st = ''
idx = -1
for i in range(len(s)):
	if s[i] == '[':
		idx = i
		break
if idx == -1:
	print(-1)
	exit()
idxl = -1
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']' and i > idx:
		idxl = i
		break
if idxl == -1:
	print(-1)
	exit()
col = col2 = -1
for i in range(len(s)):
	if s[i] == ':' and i > idx and (i < idxl):
		col = i
		break
if col == -1:
	print(-1)
	exit()
for i in range(len(s) - 1, -1, -1):
	if s[i] == ':' and i > col and (i < idxl):
		col2 = i
		break
if col2 == -1:
	print(-1)
	exit()
ans = 0
for i in range(col + 1, col2):
	if s[i] == '|':
		ans += 1
print(4 + ans)


def verifyAccordion(opBracket, opColon, closBracket, closColon):
	if opBracket == -1 or opColon == -1 or closBracket == -1 or (closColon == -1):
		return False
	if opBracket < opColon < closColon < closBracket:
		return True
	else:
		return False

def solveProblemB():
	s = input()
	initialLenOfS = len(s)
	opBracket = -1
	opColon = -1
	closBracket = -1
	closColon = -1
	for i in range(initialLenOfS):
		if ord(s[i]) == 91:
			opBracket = i
			break
	for i in range(opBracket + 1, initialLenOfS):
		if ord(s[i]) == 58:
			opColon = i
			break
	for i in range(initialLenOfS - 1, -1, -1):
		if ord(s[i]) == 93:
			closBracket = i
			break
	for i in range(closBracket - 1, -1, -1):
		if ord(s[i]) == 58:
			closColon = i
			break
	isPossible = verifyAccordion(opBracket, opColon, closBracket, closColon)
	if not isPossible:
		print(-1)
	else:
		verticalLines = 0
		for i in range(opColon + 1, closColon):
			if ord(s[i]) == 124:
				verticalLines += 1
		finalLen = verticalLines + 4
		print(finalLen)
solveProblemB()


s = input()
if '[' not in s or ']' not in s:
	print(-1)
	exit()
s = s[s.index('['):]
if ']' not in s:
	print(-1)
	exit()
s = s[:s.rindex(']')]
if s.count(':') < 2:
	print(-1)
	exit()
ans = 4 + s[s.index(':'):s.rindex(':')].count('|')
print(ans)


s = input()
ans = 4
i1 = -1
i2 = -1
i3 = -1
i4 = -1
for i in range(len(s)):
	if s[i] == '[':
		i1 = i
		break
for i in range(i1 + 1, len(s)):
	if s[i] == ':':
		i2 = i
		break
for i in range(len(s) - 1, i2, -1):
	if s[i] == ']':
		i3 = i
		break
for i in range(i3 - 1, i2, -1):
	if s[i] == ':':
		i4 = i
		break
if i1 == -1 or i2 == -1 or i3 == -1 or (i4 == -1):
	print(-1)
else:
	for i in range(i2 + 1, i4):
		if s[i] == '|':
			ans += 1
	print(ans)


s = input()
i1 = -1
i2 = -1
k1 = -1
k2 = -1
c = 0
for i in range(len(s)):
	if s[i] == '[':
		i1 = i
		break
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']':
		i2 = i
		break
for i in range(i1, i2 + 1):
	if s[i] == ':':
		k1 = i
		break
for i in range(i2, i1 - 1, -1):
	if s[i] == ':':
		k2 = i
		break
for i in range(k1, k2 + 1):
	if s[i] == '|':
		c += 1
if i1 == -1 or i2 == -1 or i1 >= i2 or (k1 == -1) or (k2 == -1) or (k1 == k2):
	print(-1)
else:
	print(4 + c)


def main():
	string = input()
	start = False
	test1 = False
	test2 = False
	for front in range(len(string)):
		if start:
			if string[front] == ':':
				test1 = True
				break
		elif string[front] == '[':
			start = True
	end = False
	for back in range(len(string) - 1, front, -1):
		if end:
			if string[back] == ':':
				test2 = True
				break
		elif string[back] == ']':
			end = True
	if test1 and test2:
		count = 4
		for x in range(front + 1, back):
			if string[x] == '|':
				count += 1
		print(count)
	else:
		print(-1)
main()


k = input()
a = k.find('[')
b = k.rfind(']')
count = 0
if b > a:
	x = k[a:b].find(':')
	m = k[a:b].count(':')
	y = k[a:b].rfind(':')
	f = k[a:b + 1]
	if y > x:
		print(4 + f[x:y].count('|'))
	else:
		print(-1)
else:
	print(-1)


s = input()
tmp = s[::-1]
a = s.find('[')
b = tmp.find(']')
if a == -1 or b == -1 or a >= len(s) - b:
	print(-1)
	exit()
s = s[a:len(s) - b]
tmp = s[::-1]
a = s.find(':')
b = tmp.find(':')
if a == -1 or b == -1 or a == len(s) - b - 1:
	print(-1)
	exit()
(k, l) = (0, 0)
ans = 0
for i in range(1, len(s) - 1):
	if s[i] == ':':
		k = i
		break
for i in range(len(s) - 1, 0, -1):
	if s[i] == ':':
		l = i
		break
for i in range(k + 1, l):
	if s[i] == '|':
		ans += 1
print(ans + 4)


s = input()
ans = 0
(i, j) = (0, len(s) - 1)
while i < j and s[i] != '[':
	i += 1
while j > i and s[j] != ']':
	j -= 1
if i > j:
	print(-1)
else:
	ans += 2
	i += 1
	j -= 1
	while i < j and s[i] != ':':
		i += 1
	while j > i and s[j] != ':':
		j -= 1
	if i >= j:
		print(-1)
	else:
		ans += 2
		i += 1
		j -= 1
		while i <= j:
			if s[i] == '|':
				ans += 1
			i += 1
		print(ans)


s = input()
(sb, eb, sc, ec) = (-1, -1, -1, -1)
for i in range(len(s)):
	if s[i] == '[' and sb == -1:
		sb = i
	elif s[i] == ']':
		eb = i
	elif s[i] == ':' and sc == -1 and (sb != -1):
		sc = i
if eb <= sb or sc > eb:
	print(-1)
elif sb == -1 or eb == -1 or sc == -1:
	print(-1)
else:
	for i in range(sc + 1, eb):
		if s[i] == ':':
			ec = i
	if ec == -1:
		print(-1)
	else:
		cnt = 0
		for i in range(sc, ec):
			if s[i] == '|':
				cnt += 1
		print(cnt + 4)


base = '[::]'
s = input()
bp = 0
for i in range(len(s)):
	if bp < len(base) and s[i] == base[bp]:
		bp += 1
ok = 1
if bp != len(base):
	ok = 0
if ok:
	firstb = -1
	lastb = -1
	firstcol = -1
	lastcol = -1
	lines = []
	for i in range(len(s)):
		if s[i] == '[':
			if firstb == -1:
				firstb = i
				break
	for i in range(len(s) - 1, -1, -1):
		if s[i] == ']' and lastb == -1:
			lastb = i
			break
	for i in range(firstb, len(s)):
		if s[i] == ':' and firstcol == -1:
			firstcol = i
			break
	for i in range(lastb, -1, -1):
		if s[i] == ':' and lastcol == -1:
			lastcol = i
			break
	for i in range(firstcol, lastcol):
		if s[i] == '|':
			lines.append(i)
	print(4 + len(lines))
else:
	print(-1)


string = input()
slova = 0
duzina = len(string)
w = 0
a = string.find('[')
b = string.rfind(']')
if a == -1 or b == -1:
	print(-1)
else:
	string = string[a:b + 1]
	dvotocke = string.count(':')
	if dvotocke < 2:
		print(-1)
	else:
		a = string.find(':')
		b = string.rfind(':')
		string = string[a:b + 1]
		w = string.count('|')
		print(w + 4)


v = input()
try:
	i = v.index(':', v.index('['))
	r = v.count('|', i, v.rindex(':', i + 1, v.rindex(']', i))) + 4
except:
	r = -1
print(r)


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

def si():
	return input()

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

def li():
	return list(mi())
s = si()
l = len(s)
pos = -1
for i in range(l):
	if s[i] == '[':
		pos = i
		break
if pos == -1:
	print(-1)
	exit()
b = -1
for i in range(l - 1, -1, -1):
	if s[i] == ']' and i > pos:
		b = i
		break
if b == -1:
	print(-1)
	exit()
c = -1
for i in range(l):
	if s[i] == ':' and i < b and (i > pos):
		c = i
		break
if c == -1:
	print(-1)
	exit()
c2 = -1
for i in range(l - 1, -1, -1):
	if s[i] == ':' and i < b and (i > c):
		c2 = i
		break
if c2 == -1:
	print(-1)
	exit()
ctr = 0
for i in range(c + 1, c2):
	if s[i] == '|':
		ctr += 1
print(ctr + 4)


n = input()
max = -1
firstColon = -1
lastColon = -1
openBracket = -1
closeBracket = -1
for i in range(len(n) - 1, -1, -1):
	if n[i] == ']':
		closeBracket = i
		break
for i in range(len(n)):
	if openBracket == -1 and n[i] == '[':
		openBracket = i
	if firstColon == -1 and n[i] == ':' and (openBracket != -1) and (i < closeBracket):
		firstColon = i
	if n[i] == ':' and openBracket != -1 and (i < closeBracket):
		lastColon = i
size = 0
for i in range(firstColon, lastColon):
	if n[i] == '|':
		size += 1
if openBracket != -1 and closeBracket != -1 and (firstColon != lastColon) and (openBracket < closeBracket):
	max = size + 4
print(max)


s = input()
s_mod = ''
FLAG = 0
for letter in s:
	if FLAG == 0 and letter != '[':
		pass
	elif FLAG == 0 and letter == '[':
		s_mod += letter
		FLAG = 1
	elif FLAG == 1 and letter == ':':
		s_mod += letter
		FLAG = 2
	elif FLAG == 2 and (letter == '|' or letter == ':' or letter == ']'):
		s_mod += letter
if FLAG != 2:
	print(-1)
	exit()
FLAG = 0
s_mod2 = ''
for letter in s_mod[:1:-1]:
	if FLAG == 0 and letter != ']':
		pass
	elif FLAG == 0 and letter == ']':
		s_mod2 += letter
		FLAG = 1
	elif FLAG == 1 and letter == ':':
		s_mod2 += letter
		FLAG = 2
	elif FLAG == 2 and letter == '|':
		s_mod2 += letter
if FLAG != 2:
	print(-1)
	exit()
print(len(s_mod2) + 2)


s = input()
b = [0] * len(s)
ob = 0
cc = 0
p = -1
q = -1
count = 0
for (ind, c) in enumerate(s):
	if c == '[':
		ob = 1
	elif c == ':' and p >= 0:
		q = ind
	elif c == ':' and ob == 1 and (p < 0):
		p = ind
	elif c == ']' and q >= 0:
		cc = q
	elif c == '|':
		count += 1
	b[ind] = count
if cc > 0:
	print(4 + b[cc] - b[p])
else:
	print(-1)


def STR():
	return list(input())

def INT():
	return int(input())

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
s = STR()
n = len(s)
flag = [False, False, False, False]
r1 = -1
r2 = -1
for i in range(n):
	if s[i] == '[':
		flag[0] = True
	if s[i] == ':' and flag[0] == True:
		flag[1] = True
		r1 = i
		break
if r1 == -1:
	print('-1')
	exit(0)
for i in range(n - 1, r1, -1):
	if s[i] == ']':
		flag[-1] = True
	if s[i] == ':' and flag[-1] == True:
		flag[-2] = True
		r2 = i
		break
if r2 == -1:
	print('-1')
	exit(0)
c = 0
for i in range(r1 + 1, r2):
	if s[i] == '|':
		c += 1
print(c + 4)


import math
q = 1
for _ in range(q):
	s = list(input())
	n = len(s)
	flag1 = False
	ans = 4
	mark = -1
	for i in range(n):
		if s[n - i - 1] == ']':
			flag1 = True
		if s[n - i - 1] == ':' and flag1:
			mark = n - i - 1
			break
	flag1 = False
	flag2 = False
	flag3 = False
	for i in range(n):
		if s[i] == '[':
			flag1 = True
		if s[i] == ':' and flag1:
			flag2 = True
			if mark > i:
				flag3 = True
		if s[i] == '|' and flag1 and flag2 and (i < mark):
			ans += 1
	if mark == -1:
		print(-1)
	elif flag3:
		print(ans)
	else:
		print(-1)


a = input()
z = a.find('[')
if z == -1:
	exit(print(-1))
f = z
a = a[z:]
z = a.rfind(']')
if z == -1:
	exit(print(-1))
a = a[:z]
z = a.find(':')
if z == -1:
	exit(print(-1))
a = a[z + 1:]
z = a.rfind(':')
if z == -1:
	exit(print(-1))
a = a[:z]
print(a.count('|') + 4)


s = input()
a = -1
for i in range(len(s)):
	if s[i] == '[':
		a = i
		break
if a == -1:
	print('-1')
	exit()
b = -1
for i in range(a + 1, len(s)):
	if s[i] == ':':
		b = i
		break
if b == -1:
	print('-1')
	exit()
d = -1
for i in range(len(s) - 1, b, -1):
	if s[i] == ']':
		d = i
		break
if d == -1:
	print('-1')
	exit()
c = -1
for i in range(d - 1, b, -1):
	if s[i] == ':':
		c = i
		break
if c == -1:
	print('-1')
	exit()
ct = 0
for i in range(b, c):
	if s[i] == '|':
		ct += 1
print(ct + 4)


s = input()
lb = -1
lc = -1
rc = len(s)
rb = len(s)
for (i, c) in enumerate(s):
	if c == '[' and lb == -1:
		lb = i
	if c == ':' and lb != -1 and (lc == -1):
		lc = i
for j in range(len(s)):
	i = len(s) - j - 1
	c = s[i]
	if c == ']' and rb == len(s):
		rb = i
	if c == ':' and rb != len(s) and (rc == len(s)):
		rc = i
if lb == -1 or lc == -1 or rc == len(s) or (rb == len(s)) or (rc <= lc):
	print(-1)
else:
	ans = 4
	for i in range(lc, rc):
		if s[i] == '|':
			ans += 1
	print(ans)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
s = input()[:-1]
n = len(s)
(a, b, c, d) = (-1, -1, -1, -1)
for i in range(n):
	if a != -1 and b != -1:
		break
	if s[i] == '[' and a == -1:
		a = i
	elif s[i] == ':' and b == -1 and (a != -1):
		b = i
for i in range(n - 1, -1, -1):
	if c != -1 and d != -1:
		break
	if s[i] == ']' and d == -1:
		d = i
	elif s[i] == ':' and c == -1 and (d != -1):
		c = i
if a == -1 or b == -1 or c == -1 or (d == -1) or (a >= d) or (b >= c):
	print(-1)
else:
	x = 4
	for i in range(b + 1, c):
		if s[i] == '|':
			x += 1
	print(x)


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
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
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 testingMode:
		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
testingMode = False
optimiseForReccursion = False

def is_Valid(a, b):
	x = min(a, b)
	y = max(a, b)
	diff = y - x
	y = y - 2 * diff
	x = x - 1 * diff
	if x >= 0 and y >= 0 and (x % 3 == 0) and (y % 3 == 0):
		return True
	return False

def main():
	s = list(input())
	stage = 0
	bonus_till_last_colon = 0
	bonus_till_close = 0
	bonus = 0
	done = 0
	count = 0
	for i in s:
		if i == '[' and stage == 0:
			stage += 1
		elif i == ':' and stage == 1:
			stage += 1
		elif stage == 2:
			if i == '|':
				bonus += 1
			elif i == ':':
				bonus_till_last_colon = bonus
				done = 1 if done == 0 else done
			elif i == ']':
				bonus_till_close = bonus_till_last_colon
				done = 2 if done == 1 else done
	if done == 2:
		print(bonus_till_close + 4)
	else:
		print(-1)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


def main():
	s = input()
	count = 0
	stack = []
	n = len(s)
	for i in range(n):
		if s[i] == '[':
			stack.append(i)
			break
	if not stack:
		print(-1)
		return
	index = stack[-1]
	for i in range(index + 1, n):
		if s[i] == ':':
			stack.append(i)
			break
	if len(stack) < 2:
		print(-1)
		return
	index = stack[-1]
	for i in range(n - 1, index, -1):
		if s[i] == ']':
			stack.append(i)
			break
	if len(stack) < 3:
		print(-1)
		return
	index = stack[-1]
	for i in range(index - 1, stack[-2], -1):
		if s[i] == ':':
			stack.append(i)
			break
	if len(stack) < 4:
		print(-1)
		return
	(stack[2], stack[3]) = (stack[3], stack[2])
	ans = 0
	for i in range(stack[1] + 1, stack[2]):
		if s[i] == '|':
			ans += 1
	print(ans + 4)
main()


s = input()
opening_B = -1
closingB = 500002
colonfirst = -1
last_coloumns = []
straightlines = []
last_coloumn = 0
x = 0
opening = False
first_coloumn = True
for i in s:
	if not opening and i == '[':
		opening = True
		opening_B = x
		x += 1
		continue
	if opening:
		if i == ':':
			if first_coloumn:
				first_coloumn = False
				colonfirst = x
			else:
				last_coloumns.append(x)
			x += 1
			continue
		if i == '|':
			straightlines.append(x)
			x += 1
			continue
		if i == ']':
			closingB = x
	x += 1
for i in last_coloumns[::-1]:
	if i < closingB:
		last_coloumn = i
		break
bracets = 0
for i in straightlines:
	if colonfirst < i < last_coloumn:
		bracets += 1
if closingB == 500002 or colonfirst < opening_B or last_coloumn == 0 or (opening_B == -1):
	print(-1)
else:
	print(bracets + 4)


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
s = input()
res = 0
n = len(s)
st = -1
e = -1
for i in range(n):
	if s[i] == '[':
		st = i
		break
for i in range(n - 1, -1, -1):
	if s[i] == ']':
		e = i
		break
if st > e or st == -1 or e == -1:
	print(-1)
	exit(0)
a = -1
b = -1
for i in range(st, e):
	if s[i] == ':':
		a = i
		break
for i in range(e, st, -1):
	if s[i] == ':':
		b = i
		break
if a == b or a == -1 or b == -1:
	print(-1)
	exit(0)
count = 0
for i in range(a, b):
	if s[i] == '|':
		count += 1
print(4 + count)


gi = lambda : list(map(int, input().strip().split()))
s = input()
n = len(s)
if '[' not in s:
	print(-1)
	exit()
l = s.index('[')
s = s[l + 1:]
if ']' not in s:
	print(-1)
	exit()
r = len(s) - 1 - s[::-1].index(']')
s = s[:r]
if ':' not in s:
	print(-1)
	exit()
s = s[s.index(':') + 1:]
if ':' not in s:
	print(-1)
	exit()
s = s[:len(s) - 1 - s[::-1].index(':')]
print(s.count('|') + 4)


s = input()
(start_bracket, end_bracket, start_col, end_col, count) = (-1, -1, -1, -1, 0)
for i in range(len(s)):
	if s[i] == '[' and start_bracket == -1:
		start_bracket = i
	if s[i] == ':' and start_col == -1 and (start_bracket != -1):
		start_col = i
		break
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']' and end_bracket == -1:
		end_bracket = i
	if s[i] == ':' and end_col == -1 and (end_bracket != -1):
		end_col = i
		break
if start_bracket >= end_bracket or start_col >= end_col or start_col == -1:
	print(-1)
else:
	for i in range(start_col + 1, end_col):
		if s[i] == '|':
			count += 1
	print(count + 4)


s = input()
if not '[' in s:
	print(-1)
	exit(0)
s = s.partition('[')[2]
if not ':' in s:
	print(-1)
	exit(0)
s = s.partition(':')[2]
if not ']' in s:
	print(-1)
	exit(0)
s = s.rpartition(']')[0]
if not ':' in s:
	print(-1)
	exit(0)
s = s.rpartition(':')[0]
print(list(s).count('|') + 4)


import sys
input = sys.stdin.readline
s = input()
n = len(s)
a = n
b = 0
for i in range(n):
	if s[i] == '[':
		a = i
		break
for i in range(n - 1, -1, -1):
	if s[i] == ']':
		b = i
		break
if a > b:
	print(-1)
	exit()
c = n
d = 0
for i in range(a + 1, b):
	if s[i] == ':':
		c = i
		break
for i in range(b, a, -1):
	if s[i] == ':':
		d = i
		break
if c >= d:
	print(-1)
	exit()
s = s[c:d + 1]
print(4 + s.count('|'))


s = input().split(':')
a = []
for i in s:
	a.append(i)
n = len(a)
startindex = -1
endindex = len(a)
while startindex < n - 1:
	startindex += 1
	if '[' in a[startindex]:
		break
while endindex > 0:
	endindex -= 1
	if ']' in a[endindex]:
		break
if startindex == n - 1:
	print('-1')
elif endindex == 0:
	print('-1')
elif endindex - startindex < 2:
	print('-1')
else:
	count = 0
	for i in range(startindex + 1, endindex):
		temp = a[i].count('|')
		count += temp
	print(count + 4)


line: str = input()
ans = 0
try:
	left = line.index('[')
	right = line.rindex(']')
	if left >= right:
		raise Exception()
	ans += 2
	line = line[left + 1:right]
	left = line.index(':')
	right = line.rindex(':')
	if left >= right:
		raise Exception()
	ans += 2
	line = line[left + 1:right]
	for c in line:
		if c == '|':
			ans += 1
	print(ans)
except Exception:
	print(-1)


ac = list(input())
r = {}
tr1 = True
tr2 = False
for i in range(len(ac)):
	if tr1 and ac[i] == '[':
		r['['] = i
		tr1 = False
		tr2 = True
	if tr2 and ac[i] == ':':
		r[':'] = [i]
		tr2 = False
flag = True
if tr1 == False and tr2 == False:
	tr3 = True
	tr4 = False
	for i in range(len(ac) - 1, -1, -1):
		if tr3 and ac[i] == ']':
			r[']'] = i
			tr3 = False
			tr4 = True
		if tr4 and ac[i] == ':':
			r[':'].append(i)
			tr4 = False
	if tr3 == False and tr4 == False and (r[':'][0] < r[':'][1]) and (r['['] < r[']']):
		c = 0
		for i in range(r[':'][0] + 1, r[':'][1]):
			if ac[i] == '|':
				c += 1
		print(c + 4)
		flag = False
if flag:
	print(-1)


s = input()
a = []
for i in s:
	if i in ['[', ']', ':', '|']:
		a.append(i)
fb = -1
fc = -1
sc = -1
sb = -1
for i in range(len(a)):
	if a[i] == '[':
		fb = i
		for j in range(i + 1, len(a)):
			if a[j] == ':':
				fc = j
				break
		break
for i in range(len(a) - 1, fc, -1):
	if a[i] == ']':
		sb = i
		for j in range(sb - 1, fc, -1):
			if a[j] == ':':
				sc = j
				break
		break
cnt = 0
for i in range(fc + 1, sc):
	if a[i] == '|':
		cnt += 1
if fb == -1 or fc == -1 or sc == -1 or (sb == -1):
	print(-1)
else:
	print(cnt + 4)


st = input()
val = 0
f1 = 0
f2 = 0
count = 0
for i in range(len(st)):
	if val == 0 and st[i] == '[':
		val += 1
	elif val == 1 and st[i] == ':':
		val += 1
		f1 = i
		break
if val == 2:
	for i in range(len(st) - 1, f1, -1):
		if val == 2 and st[i] == ']':
			val += 1
		elif val == 3 and st[i] == ':':
			val += 1
			f2 = i
			break
for i in range(f1, f2):
	if st[i] == '|':
		count += 1
if val == 4:
	print(count + 4)
else:
	print(-1)


s = input()
fs = ''
fd = ''
ss = ''
sd = ''
for i in range(len(s)):
	if s[i] == '[':
		fs = i
		break
if fs == '':
	print(-1)
	exit(0)
for i in range(fs + 1, len(s)):
	if s[i] == ':':
		fd = i
		break
if fd == '':
	print(-1)
	exit(0)
for i in range(len(s) - 1, fd, -1):
	if s[i] == ']':
		ss = i
		break
if ss == '':
	print(-1)
	exit(0)
for i in range(ss - 1, fd, -1):
	if s[i] == ':':
		sd = i
		break
if sd == '':
	print(-1)
	exit(0)
ans = 4
for i in range(fd + 1, sd):
	if s[i] == '|':
		ans += 1
print(ans)


def main():
	buf = input()
	s = ''
	for (_, c) in enumerate(buf):
		if c == '[' or c == ']' or c == ':' or (c == '|'):
			s += c
	if len(s) < 4:
		print(-1)
		return
	idx_brl = None
	idx_col = None
	idx_cor = None
	idx_brr = None
	for (i, c) in enumerate(s):
		if c == '[' and idx_brl == None:
			idx_brl = i
		if c == ']':
			idx_brr = i + 1
	if idx_brl == None or idx_brr == None:
		print(-1)
		return
	if idx_brl >= idx_brr:
		print(-1)
		return
	for i in range(idx_brl, idx_brr):
		if s[i] == ':':
			if idx_col == None:
				idx_col = i
			idx_cor = i + 1
	if idx_col == None or idx_cor == None:
		print(-1)
		return
	if idx_col >= idx_cor - 1:
		print(-1)
		return
	accordion_length = 4
	for i in range(idx_col, idx_cor):
		if s[i] == '|':
			accordion_length += 1
	print(accordion_length)
main()


a = ['|', '[', ':', ']']
s = input()
d = {}
for i in s:
	d[i] = d.get(i, 0) + 1
for i in a[1:]:
	if i not in d:
		exit(print(-1))
i = 0
j = len(s) - 1
ans = 0
fo = False
fc = False
os = False
cs = False
c = 0
while i < j:
	if s[j] == ']':
		fc = True
	if s[i] == '[':
		fo = True
	if fc == True and s[j] == ':':
		cs = True
	if fo == True and s[i] == ':':
		os = True
	if fo == True and os == True and (s[i] == '|'):
		c += 1
	if fc == True and cs == True and (s[j] == '|'):
		c += 1
	if os == False:
		i += 1
	else:
		j -= 1
if os == True and cs == True:
	print(4 + c)
else:
	print(-1)


s = input()
res = -1
fb = s.find('[')
if fb > -1:
	fc = s.find(':', fb)
	if fc > -1:
		lb = s.rfind(']', fc)
		if lb > -1:
			lc = s.rfind(':', fc + 1, lb)
			if lc > -1:
				res = 4 + s[fc:lc].count('|')
print(res)


import re

def findBeetween(symb, inp):
	(x, y) = (inp.find(symb[0]), len(inp) - inp[::-1].find(symb[1]))
	if x != -1 and y <= len(inp) and (x < y - 1):
		return inp[x + 1:y - 1]
	return None
r = input()
x = findBeetween('[]', r)
if x is not None:
	y = findBeetween('::', x)
	if y is not None:
		print(len(re.sub('[^|]', '', y)) + 4)
	else:
		print(-1)
else:
	print(-1)


s = input()
i = 0
ii = len(s)
while i < len(s):
	if s[i] == '[':
		ii = i
		i = len(s) + 1
	i += 1
if ii == len(s):
	print('-1')
	quit()
i = ii + 1
ii = len(s)
while i < len(s):
	if s[i] == ':':
		ii = i
		i = len(s) + 1
	i += 1
if ii == len(s):
	print('-1')
	quit()
jj = -1
j = len(s) - 1
while j > ii:
	if s[j] == ']':
		jj = j
		j = -1
	j -= 1
if jj == -1:
	print('-1')
	quit()
j = jj - 1
jj = -1
while j > ii:
	if s[j] == ':':
		jj = j
		j = -1
	j -= 1
if jj == -1:
	print('-1')
	quit()
ans = 4
k = ii + 1
while k < jj:
	if s[k] == '|':
		ans += 1
	k += 1
print(ans)


s = list(input())
n = len(s)
try:
	res = s.index('[')
	s = s[res + 1:]
	res += s.index(':')
	s = s[s.index(':') + 1:][::-1]
	res += s.index(']')
	s = s[s.index(']') + 1:]
	res += s.index(':')
	s = s[s.index(':') + 1:]
	res += len(s) - s.count('|')
	print(n - res)
except ValueError:
	print(-1)


s = input()
n = len(s)

def r1(s):
	i = 0
	while s[i] != '[' and i < n - 3:
		i += 1
	i += 1
	while s[i] != ':' and i < n - 2:
		i += 1
	if i == n - 2:
		return -1
	rone = i
	i = n - 1
	while s[i] != ']' and i > 2:
		i -= 1
	i -= 1
	while s[i] != ':' and i > 1:
		i -= 1
	if i == 1:
		return -1
	rtwo = i
	if rone >= rtwo:
		return -1
	res = 4
	for i in range(rone + 1, rtwo):
		if s[i] == '|':
			res += 1
	return res
if n < 4:
	print(-1)
else:
	print(r1(s))


s = input()
rev = s[::-1]
left = s.find('[')
if left != -1:
	left = s.find(':', left)
right = rev.find(']')
if right != -1:
	right = rev.find(':', right)
if left == -1 or right == -1:
	print(-1)
	return
right = len(s) - right - 1
if left >= right:
	print(-1)
	return
print(4 + s[left:right].count('|'))


s = input()
ans = -1
left = 0
right = len(s) - 1
lok = 1
while left < len(s):
	if s[left] == '[':
		lok = 2
		left += 1
	elif s[left] == ':' and lok == 2:
		break
	else:
		left += 1
rok = 1
while right >= 0:
	if s[right] == ']':
		rok = 2
		right -= 1
	elif s[right] == ':' and rok == 2:
		break
	else:
		right -= 1
if rok == lok and rok == 2 and (left < right):
	ans = 4
	while left < right:
		if s[left] == '|':
			ans += 1
		left += 1
else:
	ans = -1
print(ans)


l = list(input())
open_bracket = False
start = False
pos_close = False
finished = False
num = 0
res = []
finish = []
first = True
for char in l:
	if first:
		if not open_bracket and char == '[':
			open_bracket = True
			continue
		if open_bracket and char == ':':
			start = True
			first = False
			continue
	if not start:
		continue
	if char == '|':
		num += 1
	if char == ':':
		pos_close = True
		res.append(num)
	if pos_close and char == ']':
		finished = True
		finish.append(res[-1])
if finished:
	print(finish[-1] + 4)
else:
	print(-1)


s = input()
n = len(s)
(ii, ee) = (-1, -1)
for i in range(n):
	if s[i] == '[':
		ii = i
		break
for i in range(1, n + 1):
	if s[-i] == ']':
		ee = n - i
		break
if ii == -1 or ee == -1 or ee - ii < 3:
	print(-1)
else:
	tii = -1
	tee = -1
	for i in range(ii + 1, ee):
		if s[i] == ':':
			tii = i
			break
	for i in range(ii + 1, ee):
		if s[i] == ':' and i != tii:
			tee = i
	if tii == -1 or tee == -1 or tee - tii < 1:
		print(-1)
	else:
		print(4 + s[tii:tee].count('|'))


string = input()
removecolon = []
closingbracket = 0
initialcolon = 0
finalcolon = 0
flag = 0
n = len(string)
maxlength = 0
orstore = []
for i in range(0, n):
	if string[i] == '[':
		flag = 1
		continue
	if flag == 1:
		if string[i] == ':':
			removecolon.append(i)
		if string[i] == '|' and len(removecolon) > 0:
			orstore.append(i)
		if string[i] == ']':
			closingbracket = i
if len(removecolon) > 1:
	for j in range(len(removecolon) - 1, -1, -1):
		if removecolon[j] < closingbracket:
			finalcolon = removecolon[j]
			break
	initialcolon = removecolon[0]
	if initialcolon == finalcolon or finalcolon == 0:
		print('-1')
	else:
		for k in range(len(orstore) - 1, -1, -1):
			if initialcolon < orstore[k] < finalcolon:
				maxlength += 1
		maxlength += 4
		print(maxlength)
else:
	print('-1')


import re, math, decimal, bisect

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

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

def viread():
	return [int(_) for _ in input().strip().split()]
s = read()
b1 = s.find('[')
b2 = s.rfind(']')
c1 = s.find(':', b1)
c2 = s.rfind(':', c1, b2)
if -1 in [b1, b2, c1, c2] or c1 == c2 or b1 > b2:
	print(-1)
else:
	print(s[c1:c2].count('|') + 4)


def solve(s):
	a = s.find('[')
	b = s.find(':', a)
	d = s.rfind(']')
	c = s.rfind(':', b, d)
	if a < b < c < d:
		print(4 + s[b:c].count('|'))
	else:
		print(-1)

def main():
	s = input()
	solve(s)
main()


s = input()
l = s.find('[')
r = s.rfind(']')
cc = 0
if l > -1 and r > l + 2:
	c = s[l:r].count(':')
	s2 = s[l:r + 1]
	if c >= 2:
		ll = s2.find(':')
		rr = s2.rfind(':')
		cc = s2[ll:rr].count('|')
		print(4 + cc)
	else:
		print(-1)
else:
	print(-1)


c = input()
acc = [0, 0, -1, 0, 0]
acc[0] = c.find('[')
acc[1] = c.find(':', acc[0])
acc[4] = c.rfind(']')
acc[3] = c.rfind(':', acc[1], acc[4])
if len(acc) != len(set(acc)) or acc[0] > acc[4]:
	print(-1)
	exit()
count = 4 + c[acc[1]:acc[3]].count('|')
print(count)


s = input()

def findLR(s, char1, char2, l, r):
	n = len(s)
	while l < n and s[l] != char1:
		l += 1
	while r >= 0 and s[r] != char2:
		r -= 1
	return (l, r)

def solve(s):
	(l, r) = findLR(s, '[', ']', 0, len(s) - 1)
	if l >= r:
		return '-1'
	(l, r) = findLR(s, ':', ':', l, r)
	if l >= r:
		return '-1'
	pipes = 0
	while l <= r:
		if s[l] == '|':
			pipes += 1
		l += 1
	return 4 + pipes
print(solve(s))


s = input()
n = len(s)
ob = -1
col1 = -1
col2 = -1
cb = -1
for i in range(n):
	if ob == -1 and s[i] == '[':
		ob = i
	elif ob >= 0 and s[i] == ':':
		col1 = i
		break
for i in range(n)[::-1]:
	if cb == -1 and s[i] == ']':
		cb = i
	elif cb >= 0 and s[i] == ':':
		col2 = i
		break
if -1 in [ob, col1, cb, col2]:
	print(-1)
elif col1 >= col2:
	print(-1)
else:
	print(4 + s[col1:col2].count('|'))


s = input()
i = 0
while i < len(s) and s[i] != '[':
	i += 1
if i < len(s):
	a = []
	for j in range(i + 1, len(s)):
		if s[j] == ']':
			a.append(j)
	if len(a) > 0:
		k = a[len(a) - 1]
		s1 = 0
		b = []
		for z in range(i + 1, k):
			if s[z] == ':':
				s1 += 1
				b.append(z)
		if s1 > 1:
			s2 = 0
			for z in range(b[0] + 1, b[len(b) - 1]):
				if s[z] == '|':
					s2 += 1
			print(4 + s2)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


import sys
import math

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

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

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

def read_string_list(delim=' '):
	return input().strip().split(delim)
s = read_string()
first = s.find('[', 0, len(s))
second = s.find(':', first, len(s))
fourth = s.rfind(']')
third = s.rfind(':', second, fourth)
if first == -1 or second == -1 or third == -1 or (fourth == -1):
	print(-1)
	sys.exit()
if first < second < third < fourth:
	counter = 0
	for i in range(second, third):
		if s[i] == '|':
			counter += 1
	print(counter + 4)
else:
	print(-1)


s = input()
is_open = False
left_panel = False
k = 0
right_panel = False
is_closed = False
beg = s.find('[')
end = s.rfind(']')
if beg == -1 or end == -1 or beg > end:
	print(-1)
else:
	s = s[beg + 1:end]
	beg = s.find(':')
	end = s.rfind(':')
	if beg == -1 or beg == end:
		print(-1)
	else:
		s = s[beg + 1:end]
		k = sum([1 if s[i] == '|' else 0 for i in range(len(s))])
		print(4 + k)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, groupby, zip_longest, permutations
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
s = S()
a = s.find('[')
b = s.find(':', a + 1)
c = s.rfind(']', b + 1)
d = s.rfind(':', b + 1, c + 1)
arr = [a, b, c, d]
if -1 in arr:
	print(-1)
else:
	print(4 + s[b:d].count('|'))
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


def f(s):
	opener = -1
	closer = -1
	colon1 = -1
	colon2 = -1
	straight = []
	n = len(s)
	for (i, char) in enumerate(s):
		if char == '[':
			opener = i
			break
	if opener == -1:
		return -1
	for i in range(opener, n - 1):
		if s[i] == ':':
			colon1 = i
			break
	if colon1 == -1:
		return -1
	for i in range(n - 1, colon1, -1):
		if s[i] == ']':
			closer = i
			break
	if closer == -1:
		return -1
	for i in range(closer, colon1, -1):
		if s[i] == ':':
			colon2 = i
			break
	if colon2 == -1:
		return -1
	for i in range(colon1, colon2, 1):
		if s[i] == '|':
			straight.append(i)
	return 4 + len(straight)
s = input()
output = int(f(s))
print(str(output))


s = input()
arr = []
for i in s:
	if i == ':' or i == '[' or i == ']' or (i == '|'):
		arr.append(i)
index = 0
df = 0
for i in range(len(arr)):
	if arr[i] != '[':
		continue
	else:
		df = 1
		index = i
		break
arr = arr[index:]
index = len(arr)
for i in range(len(arr) - 1, -1, -1):
	if arr[i] != ']':
		continue
	else:
		f11 = 1
		index = i
		break
if index == len(arr):
	print(-1)
	exit()
arr = arr[0:index + 1]
if len(arr) < 4:
	print(-1)
	exit()
index = 0
f1 = 0
for i in range(len(arr)):
	if arr[i] == ':':
		index = i
		f1 = 1
		break
	else:
		continue
ind2 = 0
f2 = 0
for i in range(len(arr) - 1, -1, -1):
	if arr[i] == ':':
		ind2 = i
		f2 = 1
		break
	else:
		continue
if df == 0 or f11 == 0:
	print(-1)
	exit()
if f1 == 0 or f2 == 0:
	print(-1)
	exit()
if index == ind2:
	print(-1)
	exit()
ans = 4
for i in range(index + 1, ind2):
	if arr[i] == '|':
		ans += 1
print(ans)


s = list(input())
if not '[' in s or not ']' in s:
	print(-1)
else:
	a = s.index('[')
	s.reverse()
	b = len(s) - s.index(']') - 1
	s.reverse()
	s = s[a:b + 1]
	if s.count(':') < 2:
		print(-1)
	else:
		a = s.index(':')
		s.reverse()
		b = len(s) - s.index(':') - 1
		s.reverse()
		d = s[a:b + 1]
		print(d.count('|') + 4)


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
s1 = input()
s = [str(s1[i]) for i in range(len(s1))]
n = len(s)
c2 = s.count('[')
c3 = s.count(']')
fc = 0
fb = 0
lc = 0
lb = 0
c1 = 0
if c2 > 0 and c3 > 0:
	fb = s.index('[')
	lb = n - s[::-1].index(']') - 1
	s2 = s[fb:lb + 1]
	c1 = s2.count(':')
	if c1 > 1:
		fc = s2.index(':') + fb
		lc = len(s2) - s2[::-1].index(':') - 1 + fb
		l1 = [fb, fc, lc, lb]
		l2 = sorted(l1)
		if l1 == l2 and c1 > 1 and (c2 > 0) and (c3 > 0) and (lc != fc):
			print(4 + s[fc:lc + 1].count('|'))
		else:
			print('-1')
	else:
		print('-1')
else:
	print('-1')


s = input()
go = ''
last = 0
check = 0
temp = 0
for i in range(len(s)):
	if s[i] == '|' or s[i] == '[' or s[i] == ']' or (s[i] == ':'):
		go += s[i]
for i in range(len(go)):
	if go[i] == '[':
		go = go[i + 1:]
		temp = 1
		break
if len(go) == 0 or temp == 0:
	check = 1
temp = 0
for i in range(len(go)):
	if go[len(go) - i - 1] == ']':
		go = go[:len(go) - i - 1]
		temp = 1
		break
if len(go) == 0 or temp == 0:
	check = 1
temp = 0
for i in range(len(go)):
	if go[i] == ':':
		go = go[i + 1:]
		temp = 1
		break
if len(go) == 0 or temp == 0:
	check = 1
check2 = 0
for i in range(len(go)):
	if go[len(go) - i - 1] == ':':
		go = go[:len(go) - i - 1]
		check2 = 1
		break
if check == 1 or check2 == 0:
	print(-1)
else:
	ans = 4
	for i in go:
		if i == '|':
			ans += 1
	print(ans)


s = list(input())
(a, b) = (0, 0)
(start, end) = (0, 0)
c = ['[', ':', '|', ':', ']']
for i in range(len(s)):
	if s[i] == c[b]:
		b += 1
		a += 1
		start = i + 1
	if b == 2:
		break
b = 4
i = len(s) - 1
while i != 0:
	if s[i] == c[b]:
		b -= 1
		a += 1
		end = i
	if b == 2 or i <= start:
		break
	i -= 1
if a == 4:
	for i in range(start, end, 1):
		if s[i] == c[2]:
			a += 1
	print(a)
else:
	print(-1)


s = input()
(firstb, lastb, firstc, lastc) = (-1, -1, -1, -1)
(f1, g1, f2, g2) = (0, 0, 0, 0)
for i in range(len(s)):
	if s[i] == '[' and f1 == 0:
		firstb = i
		f1 = 1
		break
for i in range(len(s) - 1, -1, -1):
	if s[i] == ']' and g1 == 0:
		lastb = i
		g1 = 1
		break
for i in range(lastb - 1, firstb, -1):
	if s[i] == ':' and g2 == 0:
		lastc = i
		g2 = 1
for i in range(firstb, lastb):
	if s[i] == ':' and f2 == 0:
		firstc = i
		f2 = 1
if f1 == 0 or g1 == 0 or f2 == 0 or (g2 == 0) or (firstc == lastc) or (firstc < firstb) or (lastc > lastb):
	print(-1)
else:
	c = 0
	for i in range(firstc, lastc):
		if s[i] == '|':
			c += 1
	print(c + 4)


a = input()
ob = index = 0
v = -1
for i in range(0, len(a)):
	if not ob:
		if a[i] == '[':
			ob = 1
	elif a[i] == ':':
		index = i
		break
if index:
	cb = cc = 0
	for i in range(len(a) - 1, index, -1):
		if not cb:
			if a[i] == ']':
				cb = 1
		elif not cc:
			if a[i] == ':':
				cc = 1
				v = 4
		elif a[i] == '|':
			v += 1
print(v)


def func(b):
	mas = []
	for i in b:
		mas.append(i)
	if '[' in mas:
		while mas[0] != '[':
			x = mas.pop(0)
	else:
		print(-1)
		return
	if ']' in mas:
		while mas[-1] != ']':
			x = mas.pop(-1)
	else:
		print(-1)
		return
	if mas.count(':') >= 2:
		while mas[1] != ':':
			x = mas.pop(1)
		while mas[-1] != ':':
			x = mas.pop(-1)
	else:
		print(-1)
		return
	print(4 + mas.count('|'))
bayan = input()
func(bayan)


s = input()
l = list(s)
n = len(s)
cb = s.count(']')
count = 0
for i in range(n):
	if l[i] == ']' and count < cb - 1:
		l[i] = ''
		count += 1
ob = s.count('[')
count = 0
for i in range(n - 1, -1, -1):
	if l[i] == '[' and count < ob - 1:
		l[i] = ''
		count += 1
for i in range(n):
	if l[i] not in ['[', ']', ':', '|']:
		l[i] = ''
for i in range(n):
	if l[i] == '[':
		break
	l[i] = ''
for i in range(n - 1, -1, -1):
	if l[i] == ']':
		break
	l[i] = ''
cc = l.count(':')
if cc > 2:
	count = 0
	for i in range(n):
		if l[i] == ':' and (count == 0 or count == cc - 1):
			count += 1
		elif l[i] == ':':
			l[i] = ''
			count += 1
for i in range(n):
	if l[i] == '[':
		j = i + 1
		while j < n and l[j] != ':':
			l[j] = ''
			j += 1
		break
for i in range(n - 1, -1, -1):
	if l[i] == ']':
		j = i - 1
		while j > -1 and l[j] != ':':
			l[j] = ''
			j -= 1
		break
s = ''.join(l)
if s.count('[') != 1 or s.count(']') != 1 or s.count(':') != 2:
	print(-1)
else:
	print(len(s))


s = input()
i = s.find('[')
j = s.find(':', i)
m = s.rfind(']')
l = s.rfind(':', j + 1, m)
if i < j < l < m and i != -1 and (j != -1) and (l != -1) and (m != -1):
	count = 0
	for r in range(j + 1, l):
		if s[r] == '|':
			count = count + 1
	print(4 + count)
else:
	print(-1)


s = input()
try:
	a = s.find('[')
	b = s.find(':', a)
	c = s.rfind(']')
	d = s.rfind(':', b, c)
except:
	print(-1)
	exit(0)
if a < c and b < d and (d < c):
	temp = s[b + 1:d]
	print(temp.count('|') + 4)
else:
	print(-1)


s = input()

def sovle(s):
	i1 = s.find('[')
	if i1 == -1:
		return -1
	s = s[i1 + 1:]
	i2 = s.find(':')
	if i2 == -1:
		return -1
	s = s[i2 + 1:]
	i1 = s.rfind(']')
	if i1 == -1:
		return -1
	s = s[:i1]
	i2 = s.rfind(':')
	if i2 == -1:
		return -1
	s = s[:i2]
	x = s.count('|')
	return x + 4
print(sovle(s))


s = input()
a = []
for i in range(len(s)):
	a.append(s[i])
count = 0
f1 = False
index = -1
for k in range(len(a)):
	if a[len(a) - 1 - k] == ']':
		f1 = True
	if a[len(a) - 1 - k] == ':' and f1:
		index = len(a) - 1 - k
		break
f1 = False
f2 = False
f3 = False
for j in range(len(a)):
	if a[j] == '[':
		f1 = True
	if a[j] == ':' and f1:
		f2 = True
		if index > j:
			f3 = True
	if a[j] == '|' and f1 and f2 and (j < index):
		count += 1
if index == -1:
	print(-1)
elif f3:
	print(count + 4)
else:
	print(-1)


s = str(input())
n = len(s)
ans = 4
i = 0
flag = 0
while i < n and s[i] != '[':
	i += 1
if i == n:
	flag = 1
i += 1
while i < n and s[i] != ':':
	i += 1
if i == n:
	flag = 1
j = n - 1
while j > i and s[j] != ']':
	j -= 1
if j == i:
	flag = 1
j -= 1
while j > i and s[j] != ':':
	j -= 1
if j == i:
	flag = 1
j -= 1
while j > i:
	if s[j] == '|':
		ans += 1
	j -= 1
if flag == 1:
	print(-1)
else:
	print(ans)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	s = stdin.readline().rstrip('\n')
	n = len(s)
	l0 = 0
	while l0 < n:
		if s[l0] != '[':
			l0 = l0 + 1
		else:
			break
	l1 = l0 + 1
	while l1 < n:
		if s[l1] != ':':
			l1 = l1 + 1
		else:
			break
	l4 = n - 1
	while l4 >= 0:
		if s[l4] != ']':
			l4 = l4 - 1
		else:
			break
	l3 = l4 - 1
	while l3 >= 0:
		if s[l3] != ':':
			l3 = l3 - 1
		else:
			break
	res = -1
	if l0 < n and l0 < l1 and (l1 < l3) and (l3 < l4):
		res = 4
		for i in range(l1 + 1, l3):
			if s[i] == '|':
				res = res + 1
	stdout.write(str(res))
	return 0
main()


s = input()
alp = 'abcdefghijklmnopqrstuvwxyz'
for a in alp:
	if a in s:
		s = s.replace(a, '')
f = s.find('[')
b = s.rfind(']')
if f == -1 or b == -1 or f > b:
	print(-1)
	exit()
f1 = s[f:].find(':')
b1 = s[:b].rfind(':')
if f1 == -1 or f + f1 >= b1:
	print(-1)
	exit()
l = 0
for i in range(f + f1, b1):
	if s[i] == '|':
		l += 1
print(4 + l)


src = input()
s = ''
for ch in src:
	if ch in ['[', ']', '|', ':']:
		s = s + ch
s = list(s)

def func():
	if len(s) < 4:
		return True
	todel = 0
	while len(s) > 0 and s[todel] != '[' and (todel < len(s) - 1):
		todel += 1
	del s[:todel]
	todel = len(s) - 1
	while len(s) > 1 and s[todel] != ']' and (todel > 0):
		todel -= 1
	del s[todel:len(s) - 1]
	todel = 1
	while len(s) > 1 and s[todel] != ':' and (todel < len(s) - 1):
		todel += 1
	del s[1:todel]
	todel = len(s) - 2
	while len(s) > 2 and s[todel] != ':' and (todel > 0):
		todel -= 1
	del s[todel:len(s) - 2]
	i = 2
	todel = 2
	while i < len(s) - 2:
		if s[i] != '|':
			todel += 1
		i += 1
	del s[2:todel]
	if len(s) < 4:
		return True
if func():
	print(-1)
else:
	s = ''.join(s)
	print(len(s))


import sys
b = input()
l = 0
r = len(b) - 1
ri = li = 0
while l <= len(b) - 4 and b[l] != '[':
	l += 1
while r >= 3 and b[r] != ']':
	r -= 1
if r - l < 3:
	print(-1)
	sys.exit()
else:
	l1 = l
	r1 = r
	while l1 <= r - 2 and b[l1] != ':':
		l1 += 1
	while r1 >= l + 2 and b[r1] != ':':
		r1 -= 1
	if r1 - l1 < 1:
		print(-1)
		sys.exit()
	else:
		k = 0
		while l1 < r1:
			if b[l1] == '|':
				k += 1
			l1 += 1
		print(k + 4)


s = input()
mode = 0
l = len(s)
r = -1
for i in range(len(s)):
	if mode == 0:
		if s[i] == '[':
			mode = 1
	if mode == 1:
		if s[i] == ':':
			l = i
			break
mode = 0
for i in range(len(s) - 1, -1, -1):
	if mode == 0:
		if s[i] == ']':
			mode = 1
	if mode == 1:
		if s[i] == ':':
			r = i
			break
if l >= r:
	print(-1)
else:
	c = 0
	for i in range(l + 1, r):
		if s[i] == '|':
			c += 1
	print(c + 4)


str = input()
l = str.find('[')
r = str.rfind(']')
if l < r:
	ll = str.find(':', l, r)
	rr = str.rfind(':', l, r)
	if ll < rr:
		print(str.count('|', ll, rr) + 4)
	else:
		print(-1)
else:
	print(-1)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
s = input()
n = len(s)
start = '[:'
end = ']:'
st = -1
en = -1
ind = 0
for i in range(n):
	if s[i] == start[ind]:
		ind += 1
		if ind == 2:
			st = i
			break
ind = 0
for i in range(n - 1, -1, -1):
	if s[i] == end[ind]:
		ind += 1
		if ind == 2:
			en = i
			break
if st == -1 or en == -1 or st >= en:
	print(-1)
else:
	print(4 + s[st:en].count('|'))


s = input()
right_found = False
both_found = False
left_indexs = []

def main(s):
	try:
		left_bra_i = s.index('[')
	except:
		return -1
	try:
		right_bra_i = len(s) - s[::-1].index(']') - 1
	except:
		return -1
	if left_bra_i > right_bra_i:
		return -1
	s2 = s[left_bra_i:right_bra_i + 1]
	try:
		left_colon_i = s2.index(':')
	except:
		return -1
	try:
		right_colon_i = len(s2) - s2[::-1].index(':') - 1
	except:
		return -1
	if left_colon_i == right_colon_i:
		return -1
	s3 = s2[left_colon_i:right_colon_i]
	bar_count = 0
	for char in s3:
		if char == '|':
			bar_count += 1
	out = 4 + bar_count
	return out
print(main(s))


from collections import Counter
str = input()
bo = bc = co = cc = -1
n = len(str)
cnt = Counter(str)
if cnt['[']:
	bo = str.index('[')
if cnt[']']:
	bc = n - 1 - str[::-1].index(']')
cnt = Counter(str[bo:bc + 1])
if cnt[':']:
	co = str[bo:bc + 1].index(':')
	cc = str[bo:bc + 1].rindex(':')
if bo == -1 or bc == -1 or co == -1 or (cc == -1) or (co == cc):
	print(-1)
else:
	str = list(str)
	ans = 4
	for i in range(bo + co, bo + cc + 1):
		if str[i] == '|':
			ans += 1
	print(ans)


def solve(s):
	if s.find('[') == -1:
		return -1
	s = s[s.find('['):]
	if s.find(':') == -1:
		return -1
	s = s[s.find(':') + 1:]
	if s.find(']') == -1:
		return -1
	s = s[:s.rfind(']')]
	if s.find(':') == -1:
		return -1
	s = s[:s.rfind(':')]
	return s.count('|') + 4
s = input()
print(solve(s))


s = input()
lp = s.find('[')
rp = s.rfind(']')
lc = s[lp:rp + 1].find(':')
lc += lp
rc = s[lp:rp + 1].rfind(':')
rc += lp
x = s[lc:rc].count('|')
if lp == -1 or rp == -1 or lc == rc:
	print(-1)
else:
	print(x + 4)


def find_b(s):
	l = s.find('[')
	r = s.rfind(']')
	if l == -1 or r == -1:
		return -1
	l = s.find(':', l, r)
	r = s.rfind(':', l, r)
	if l == -1 or r == -1 or l == r:
		return -1
	return s.count('|', l + 1, r) + 4
s = input()
print(find_b(s))


s = input()
a1 = s.find('[')
d = s[::-1].find(']')
a2 = len(s) - 1 - d
q = '[:'
b1 = s[a1:a2 + 1].find(':') + a1
e = s[a1:a2 + 1][::-1].find(':')
b2 = len(s) - 1 - e - d
if a1 < a2 and b1 < b2 and (a1 != -1) and (d != -1) and (b1 != -1) and (e != -1):
	for i in range(b1 + 1, b2 + 1):
		if s[i] == '|':
			q += '|'
	print(len(q) + 2)
else:
	print(-1)


from sys import stdin, stdout
s = stdin.readline()
s = s[0:-1]
if '[' not in s:
	stdout.write(str(-1))
else:
	i1 = s.index('[')
	s = s[i1:]
	if ']' not in s:
		stdout.write(str(-1))
	else:
		rs = s[::-1]
		i2 = rs.index(']')
		rs = rs[i2:]
		s = rs[::-1]
		i1 = s.index('[')
		i2 = s.index(']')
		if s.count(':') <= 1:
			stdout.write(str(-1))
		else:
			i3 = s.index(':')
			rs = s[::-1]
			i4 = rs.index(':')
			i4 = len(rs) - i4 - 1
			stdout.write(str(s[i3:i4].count('|') + 4))


s = str(input())
a = s.find('[')
s = s[::-1]
b = len(s) - s.find(']') - 1
s = s[::-1]
if s.count('[') >= 1 and s.count(']') >= 1 and (s.count(':') >= 2):
	d = s[a + 1:b]
	if d.count(':') >= 2:
		start = d.find(':')
		d = d[::-1]
		end = len(d) - 1 - d.find(':')
		d = d[::-1]
		f = d[start + 1:end]
		print(f.count('|') + 4)
	else:
		print(-1)
else:
	print(-1)


s = input()
k = 0
i = 0
f = False
while i < len(s) and (not f):
	if s[i] == '[':
		f = True
		k = i
	i += 1
if not f:
	print(-1)
	exit()
i = k
k = 0
f = False
while i < len(s) and (not f):
	if s[i] == ':':
		f = True
		k = i
	i += 1
if not f:
	print(-1)
	exit()
s = s[k + 1:len(s)]
s = s[::-1]
k = 0
i = 0
f = False
while i < len(s) and (not f):
	if s[i] == ']':
		f = True
		k = i
	i += 1
if not f:
	print(-1)
	exit()
i = k
k = 0
f = False
while i < len(s) and (not f):
	if s[i] == ':':
		f = True
		k = i
	i += 1
if not f:
	print(-1)
	exit()
s = s[k + 1:len(s)]
ans = 4 + s.count('|')
print(ans)


s = input()
a = s.find('[')
b = s.rfind(']')
from sys import exit
if a == -1 or b == -1:
	print(-1)
	exit()
if a > b:
	print(-1)
	exit()
s2 = s[a + 1:b]
a2 = s2.find(':')
b2 = s2.rfind(':')
if a2 == b2:
	print(-1)
	exit()
s3 = s2[a2 + 1:b2]
res = s3.count('|')
print(res + 4)


s = input()
n = len(s)
r = 0
a = s.find('[')
if a == -1:
	print(-1)
	exit()
r += a
s = s[a:]
a = s.find(':')
if a == -1:
	print(-1)
	exit()
s = s[a + 1:]
r += a - 1
a = s.rfind(']')
if a == -1:
	print(-1)
	exit()
r += len(s) - 1 - a
s = s[:a + 1]
a = s.rfind(':')
if a == -1:
	print(-1)
	exit()
r += len(s) - 2 - a
s = s[:a]
r += len(s) - s.count('|')
print(n - r)


n = input()
c = 0
t = 0
o = 0
ini = -1
fim = -1
if '[' in n:
	ini = n.index('[')
if ']' in n:
	fim = n.rindex(']')
if ini == -1 or fim == -1:
	c = -1
elif ini < fim:
	c += 2
	if ':' in n[ini:fim]:
		inium = n[ini:].index(':') + ini
		fimum = n[:fim].rindex(':')
		if fimum - inium > 0:
			c += 2
			c += n[inium:fimum].count('|')
		else:
			c = -1
	else:
		c = -1
else:
	c = -1
print(c)


s = str(input())
c = 0
if '[' in s and ']' in s:
	x = s.index('[')
	s = s[x:]
	if ']' in s:
		x = s.rindex(']')
		s = s[:x]
		if s.count(':') >= 2:
			x = s.index(':')
			y = s.rindex(':')
			for i in range(x, y):
				if s[i] == '|':
					c += 1
			print(4 + c)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


def main():
	raw = input()
	a = True
	b = True
	try:
		deadline_bracket = raw.rindex(']')
		deadline_colon = raw.rindex(':')
	except:
		print(-1)
		return
	if deadline_colon > deadline_bracket:
		deadline_colon = 0
		for i in range(deadline_bracket, -1, -1):
			if raw[i] == ':':
				deadline_colon = i
				break
	count = 0
	for x in range(0, deadline_colon):
		if a:
			if raw[x] == '[':
				a = False
				count += 1
			continue
		elif b:
			if raw[x] == ':':
				b = False
				count += 1
			continue
		else:
			if raw[x] == '|':
				count += 1
			continue
	if a or b:
		print(-1)
		return
	else:
		print(count + 2)
main()


import sys
s = input()

def f(c, s):
	pos = s.find(c)
	if pos == -1:
		print(pos)
		sys.exit()
	return s[pos + 1:]
s = f('[', s)
s = f(':', s)
s = s[::-1]
s = f(']', s)
s = f(':', s)
print(s.count('|') + 4)


s = input()
(c, d, e) = (4, -1, -1)
i = 0
while i < len(s):
	if s[i] == '[':
		break
	i += 1
else:
	print(-1)
	exit(0)
while i < len(s):
	if s[i] == ':':
		break
	i += 1
else:
	print(-1)
	exit(0)
i += 1
while i < len(s):
	if s[i] == '|':
		c += 1
	if s[i] == ':':
		d = c
	if s[i] == ']':
		e = d
	i += 1
print(e)


def f():
	string = input()
	if len(string) < 4:
		print('-1')
		return
	string = list(string)
	rev = list(string)
	rev.reverse()
	if '[' in string:
		one = string.index('[')
	else:
		print('-1')
		return
	if ']' in rev:
		two = len(string) - rev.index(']')
	else:
		print('-1')
		return
	sub_string = string[one:two]
	sub_string_rev = list(sub_string)
	sub_string_rev.reverse()
	if len(sub_string) < 4:
		print('-1')
		return
	cnt = sub_string.count(':')
	if cnt < 2:
		print('-1')
		return
	else:
		three = sub_string.index(':')
		four = len(sub_string_rev) - sub_string_rev.index(':')
	second_sub_string = sub_string[three:four]
	cnt2 = second_sub_string.count('|')
	print(cnt2 + 4)
f()


import sys, string, heapq
arr = list(sys.stdin.readline().rstrip())
n = len(arr)
left = 0
right = 2 * n
while left < right:
	mid = (left + right) // 2
	res = {'[': 9876543210, ':': [9876543210, -1], ']': -1}
	can = False
	for i in range(n):
		if arr[i] == '[':
			res[arr[i]] = min(res[arr[i]], i)
		elif arr[i] == ']':
			res[arr[i]] = max(res[arr[i]], i)
	if res['['] != 9876543210 and res[']'] != -1:
		for i in range(n):
			if arr[i] == ':':
				if res['['] < i < res[']']:
					res[':'][0] = min(res[':'][0], i)
					res[':'][1] = max(res[':'][1], i)
		if res[':'][0] != res[':'][1]:
			if res[':'][0] != 9876543210 and res[':'][1] != -1:
				cnt = 0
				for i in range(n):
					if arr[i] == '|' and res[':'][0] < i < res[':'][1]:
						cnt += 1
				if cnt >= mid - 4:
					can = True
	if can:
		left = mid + 1
	else:
		right = mid
print(right - 1)


import re
s = input()
s = re.sub('[a-z]', '', s)
start = s.find('[')
if start > -1:
	s = s[start:]
	end = s.rfind(']')
	if end > -1:
		s = s[:end + 1]
		start = s.find(':')
		end = s.rfind(':')
		if start != end:
			s = s[start:end + 1]
			print(s.count('|') + 4)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


from __future__ import print_function
a = input()
b = -1
c = -1
count = 4
d = 0
for i in range(len(a) - 1, -1, -1):
	if a[i] == ']':
		d += 1
	if a[i] == ':' and d > 0:
		c = i
		break
d = 0
for i in range(0, len(a)):
	if a[i] == '[':
		d += 1
	if a[i] == ':' and d > 0:
		b = i
		break
if c == -1 or b == -1 or c <= b:
	print(-1)
else:
	for i in range(b, c):
		if a[i] == '|':
			count += 1
	print(count)


def solve(a, n):
	(e, b, c, d) = (-1, -1, -1, -1)
	for i in range(n):
		if a[i] == '[':
			e = i
			break
	if e == -1 or e > n - 4:
		return -1
	for j in range(e + 1, n):
		if a[j] == ':':
			b = j
			break
	if b == -1 or b > n - 3:
		return -1
	for i in range(n - 1, -1, -1):
		if a[i] == ']':
			d = i
			break
	if d == -1 or d < 3:
		return -1
	for j in range(d - 1, -1, -1):
		if a[j] == ':':
			c = j
			break
	if c == -1 or c < 2:
		return -1
	if e < b < c < d:
		return a[b:c].count('|') + 4
	return -1
a = list(input())
n = len(a)
print(solve(a, n))


def find_char(char, s, n):
	for i in range(n):
		if s[i] == char:
			return i
	return -1

def main():
	s = input()
	n = len(s)
	index = find_char('[', s, n)
	if index == -1:
		print(-1)
		exit(0)
	s = s[index + 1:]
	index = find_char(':', s, len(s))
	if index == -1:
		print(-1)
		exit(0)
	s = s[-1:index:-1]
	index = find_char(']', s, len(s))
	if index == -1:
		print(-1)
		exit(0)
	s = s[index + 1:]
	index = find_char(':', s, len(s))
	if index == -1:
		print(-1)
		exit(0)
	s = s[index + 1:]
	count = 0
	for i in s:
		if i == '|':
			count += 1
	print(count + 4)
main()


s = str(input())
n = len(s)
ans = -1
lbracket = -1
lcolon = -1
rcolon = -1
rbracket = -1
for i in range(n):
	if lbracket == -1:
		if s[i] == '[':
			lbracket = i
	if lcolon == -1 and lbracket != -1:
		if s[i] == ':':
			lcolon = i
for i in range(n)[::-1]:
	if rbracket == -1:
		if s[i] == ']':
			rbracket = i
	if rcolon == -1 and rbracket != -1:
		if s[i] == ':':
			rcolon = i
if lbracket != -1 and lcolon != -1 and (rcolon != -1) and (rbracket != -1) and (lbracket < lcolon < rcolon < rbracket):
	bars = s[lcolon:rcolon].count('|')
	ans = bars + 4
print(ans)


s = input()
n = len(s)
c1 = -1
c2 = n
f1 = False
f2 = False
for i in range(0, n):
	if s[i] == '[' and f1 == False:
		f1 = True
	if f1 and s[i] == ':':
		c1 = i
		break
for i in range(n - 1, -1, -1):
	if s[i] == ']' and f2 == False:
		f2 = True
	if f2 and s[i] == ':':
		c2 = i
		break
ans = 0
if c1 >= c2 or c1 == -1 or c2 == n:
	print(-1)
else:
	ans += 2
	ans += 2
	for i in range(c1 + 1, c2):
		if s[i] == '|':
			ans += 1
	print(ans)


def mi():
	return map(int, input().split())
s = list(input())
for i in range(len(s)):
	if s[i] != '[' and s[i] != ']' and (s[i] != '|') and (s[i] != ':'):
		s[i] = ''
s = list(''.join(s))
ind = -1
(f1, f2) = (0, 0)
for i in range(len(s)):
	if s[i] == '[':
		f1 = 1
	if f1 and s[i] == ':':
		f2 = 1
	if f1 and f2:
		ind = i
		break
rs = s[::-1]
f1 = 0
f2 = 0
rind = -1
for i in range(len(rs)):
	if rs[i] == ']':
		f1 = 1
	if f1 and rs[i] == ':':
		f2 = 1
	if f1 and f2:
		rind = i
		break
if rind == -1 or ind == -1 or ind >= len(s) - 1 - rind:
	print(-1)
	exit(0)
c = 0
for i in range(ind, len(s) - 1 - rind + 1):
	if s[i] == '|':
		c += 1
print(c + 4)


accord = input()
open_bracket = accord.find('[')
accord = accord[open_bracket + 1:]
open_colon = accord.find(':')
accord = accord[open_colon + 1:]
close_bracket = accord.rfind(']')
close_colon = accord[:close_bracket].rfind(':')
if open_bracket == -1 or open_colon == -1 or close_bracket == -1 or (close_colon == -1):
	print(-1)
else:
	res = accord[:close_colon].count('|') + 4
	print(res)


s = input()
pat = '[::]'
(i, j) = (0, 0)
m = len(s)
n = len(pat)
while i < n and j < m:
	if s[j] == pat[i]:
		i += 1
	j += 1
if i == n:
	(fb, fc, lc, lb) = (0, 0, 0, 0)
	for k in range(m):
		if s[k] == '[':
			fb = k
			break
	for k in range(fb + 1, m):
		if s[k] == ':':
			fc = k
			break
	for k in range(m - 1, fc + 1, -1):
		if s[k] == ']':
			lb = k
			break
	for k in range(lb - 1, fc, -1):
		if s[k] == ':':
			lc = k
			break
	ans = 4
	for k in range(fc + 1, lc):
		if s[k] == '|':
			ans += 1
	print(ans)
else:
	print(-1)


st = input()
left = 0
colon1 = 0
colon2 = 0
verts = 0
last_v = 0
max = -1
for char in st:
	if char == '[':
		left = 1
	elif char == ':' and left == 1 and (colon1 != 1):
		colon1 = 1
	elif char == '|' and left == 1 and (colon1 == 1):
		verts += 1
	elif char == ':' and left == 1 and (colon1 == 1):
		colon2 = 1
		last_v = verts
	elif char == ']' and left == 1 and (colon1 == 1) and (colon2 == 1):
		max = last_v + 4
if max >= 4:
	print(max)
else:
	print(-1)


s = []
z = '[]|:'
for i in input():
	if i in z:
		s.append(i)
while len(s) and s[-1] != ']':
	s.pop()
while len(s) and s[-1] != ':':
	s.pop()
s.reverse()
while len(s) and s[-1] != '[':
	s.pop()
while len(s) and s[-1] != ':':
	s.pop()
s.reverse()
if len(s) > 1:
	print(4 + s.count('|'))
else:
	print(-1)


cadena = input()
respuesta = 0
longitud = len(cadena)
A = cadena.find('[')
if A == -1:
	respuesta = -1
b = cadena[A:].find(':')
if b == -1:
	respuesta = -1
B = b + A
cadenaMod = cadena[B + 1:]
cadenaModInv = cadenaMod[::-1]
DInv = cadenaModInv.find(']')
if DInv == -1:
	respuesta = -1
D = longitud - DInv - 1
cInv = cadenaModInv[DInv:].find(':')
if cInv == -1:
	respuesta = -1
CInv = cInv + DInv
C = longitud - CInv - 1
medio = cadena[B + 1:C]
if respuesta != -1:
	respuesta = medio.count('|') + 4
print(respuesta)


f = 4
i1 = 0
i2 = 0
l = ['[', ':']
l1 = [']', ':']
s = input()
k = -1
k1 = -1
for i in range(len(s)):
	if s[i] == l[i1]:
		i1 += 1
		if i1 == 2:
			k = i
			break
for i in range(len(s) - 1, -1, -1):
	if s[i] == l1[i2]:
		i2 += 1
		if i2 == 2:
			k1 = i
			break
if k == -1 or k1 == -1 or k >= k1:
	print(-1)
else:
	for i in range(k, k1):
		if s[i] == '|':
			f += 1
	print(f)


s = input()
o = s.find('[')
c = s.rfind(']')
if o < c and o != -1:
	t = s[o + 1:c]
	oo = t.find(':')
	cc = t.rfind(':')
	if oo < cc and oo != -1:
		print(t[oo:cc].count('|') + 4)
	else:
		print(-1)
else:
	print(-1)


import sys
s = input()
result = 0
i = 0
while i < len(s) and s[i] != '[':
	i += 1
while i < len(s) and s[i] != ':':
	i += 1
j = len(s) - 1
while j > 0 and s[j] != ']':
	j -= 1
while j > 0 and s[j] != ':':
	j -= 1
if i < j:
	result = 4
	for k in range(i, j):
		if s[k] == '|':
			result += 1
	print(result)
else:
	print(-1)


s = list(input())
n = len(s)
b1 = c1 = b2 = c2 = -1
for i in range(n):
	if s[i] == '[':
		b1 = i
		for j in range(i + 1, n):
			if s[j] == ':':
				c1 = j
				break
		break
for i in range(n - 1, -1, -1):
	if s[i] == ']':
		b2 = i
		for j in range(i, -1, -1):
			if s[j] == ':':
				c2 = j
				break
		break
ans = 0
if b1 < b2 and c1 < c2 and (b1 != -1) and (b2 != -1) and (c1 != -1) and (c2 != -1):
	for i in range(c1 + 1, c2, 1):
		if s[i] == '|':
			ans += 1
	print(4 + ans)
else:
	print(-1)


s = input()
try:
	st = s.index(':', s.index('['))
	end = s.count('|', st, s.rindex(':', st + 1, s.rindex(']', st))) + 4
except:
	end = -1
print(end)


s = str(input())
n = len(s)
for bl in range(n):
	if s[bl] == '[':
		break
else:
	print(-1)
	exit()
for br in reversed(range(n)):
	if s[br] == ']':
		break
else:
	print(-1)
	exit()
for cl in range(bl, n):
	if s[cl] == ':':
		break
else:
	print(-1)
	exit()
for cr in reversed(range(br)):
	if s[cr] == ':':
		break
else:
	print(-1)
	exit()
if bl < cl < cr < br:
	res = 4
	for i in range(cl, cr + 1):
		if s[i] == '|':
			res += 1
	print(res)
else:
	print(-1)


a = input()
q1 = -1
q2 = -1
q3 = -1
q4 = -1
L = 0
for i in range(len(a)):
	j = len(a) - i - 1
	if a[i] == '[' and q1 == -1:
		q1 = i
	if a[i] == ':' and q2 == -1 and (q1 > -1):
		q2 = i
	if a[j] == ':' and q3 == -1 and (q4 > -1):
		q3 = j
	if a[j] == ']' and q4 == -1:
		q4 = j
for i in range(q2, q3):
	if a[i] == '|':
		L += 1
if q1 > -1 and q2 > -1 and (q3 > -1) and (q4 > -1) and (q1 < q2) and (q2 < q3) and (q3 < q4):
	print(L + 4)
else:
	print(-1)


s = input()
ob = s.find('[')
cb = s.rfind(']')
fc = s[ob:cb].find(':')
sc = s[ob:cb].rfind(':')
if ob > cb or fc == sc:
	print(-1)
else:
	print(4 + s[ob + fc:ob + sc].count('|'))


s = input()
ls = len(s)
l1 = s.find('[')
r1 = ls - 1 - s[::-1].find(']')
if l1 == -1 or r1 == ls or l1 > r1:
	print(-1)
	exit(0)
l2 = s.find(':', l1 + 1, r1)
r2 = r1 - 1 - s[r1 - 1:l1:-1].find(':')
if l2 == -1 or r2 == ls or l2 == r2:
	print(-1)
	exit(0)
print(4 + s.count('|', l2 + 1, r2))


import sys
S = input()
N = len(S)
s = N + 1
for i in range(N):
	if S[i] == '[':
		s = i
		break
if s == N + 1:
	print(-1)
	sys.exit()
t = N + 1
for i in range(s, N):
	if S[i] == ':':
		t = i
		break
if t == N + 1:
	print(-1)
	sys.exit()
end = -1
for i in range(N - 1, -1, -1):
	if S[i] == ']':
		end = i
		break
if end == -1:
	print(-1)
	sys.exit()
v = -1
for i in range(end, -1, -1):
	if S[i] == ':':
		v = i
		break
if v == -1:
	print(-1)
	sys.exit()
if not t < v:
	print(-1)
	sys.exit()
num = 0
for i in range(t, v):
	if S[i] == '|':
		num += 1
print(4 + num)


s = input()
st = []
length = 0
left = 0
right = 0
brack = False
for (i, e) in list(enumerate(s)):
	if e == '[':
		brack = True
	if e == ':' and brack:
		left = i
		break
brack = False
for (i, e) in reversed(list(enumerate(s))):
	if e == ']':
		brack = True
	if e == ':' and brack:
		right = i
		break
if right == 0 or left == 0 or left >= right:
	print(-1)
else:
	for j in range(left, right):
		if s[j] == '|':
			length += 1
	print(4 + length)


a = input()
l = len(a)
i = 0
(t, q) = (0, 0)
while i < l:
	if t == 0:
		if a[i] == '[':
			t += 1
	if t == 1:
		if a[i] == ':':
			t += 1
	if t == 2:
		break
	i += 1
j = l - 1
while j >= 0:
	if q == 0:
		if a[j] == ']':
			q += 1
	if q == 1:
		if a[j] == ':':
			q += 1
	if q == 2:
		break
	j -= 1
if t == 2 and q == 2 and (i < j):
	p = 4
	k = i + 1
	while k < j:
		if a[k] == '|':
			p = p + 1
		k = k + 1
	print(p)
else:
	print(-1)


s = list(input())
out = 4
pos = 0
posL = 0
for i in range(len(s)):
	if s[i] == '[':
		s = s[i + 1:]
		break
else:
	print(-1)
	exit()
for i in range(len(s)):
	if s[i] == ':':
		s = s[i + 1:]
		break
else:
	print(-1)
	exit()
s.reverse()
for i in range(len(s)):
	if s[i] == ']':
		s = s[i + 1:]
		break
else:
	print(-1)
	exit()
for i in range(len(s)):
	if s[i] == ':':
		s = s[i + 1:]
		break
else:
	print(-1)
	exit()
out = 0
for i in s:
	if i == '|':
		out += 1
print(out + 4)


s = input()

def string(s):
	if s.find('[') != -1:
		f = s.find('[')
	else:
		return -1
	if s.rfind(']') != -1:
		l = s.rfind(']')
	else:
		return -1
	if s[f:l].find(':') != -1:
		c1 = s[f:l].find(':')
	else:
		return -1
	if s[f:l].rfind(':') != -1:
		c2 = s[f:l].rfind(':')
	else:
		return -1
	if c1 == c2:
		return -1
	else:
		line = s[f + c1:f + c2].count('|')
		return line + 4
print(string(s))


st = input()
t1 = -1
t2 = -1
t3 = -1
t4 = -1
n = len(st)
for i in range(len(st)):
	if st[i] == '[':
		t1 = i
		break
if t1 == -1:
	exit(print('-1'))
for j in range(t1 + 1, len(st)):
	if st[j] == ':':
		t2 = j
		break
if t2 == -1:
	exit(print('-1'))
for i in range(len(st) - 1, t2, -1):
	if st[i] == ']':
		t4 = i
		break
if t4 == -1:
	exit(print('-1'))
for i in range(t4 - 1, t2, -1):
	if st[i] == ':':
		t3 = i
		break
if t3 == -1:
	exit(print('-1'))
c = 0
for i in range(t2 + 1, t3):
	if st[i] == '|':
		c += 1
print(4 + c)


import sys
s = input()
s1 = ''
k = -1
k1 = -1
k2 = -1
k3 = -1
l = len(s)
for i in range(l):
	if s[i] == '[':
		k = i
		for j in range(k + 1, l):
			if s[j] == ':':
				k2 = j
				break
		break
if k == -1 or k2 == -1:
	print('-1')
	sys.exit()
for i in range(l - 1, -1, -1):
	if s[i] == ']':
		k1 = i
		for j in range(k1 - 1, -1, -1):
			if s[j] == ':':
				k3 = j
				break
		break
if k1 == -1 or k3 == -1:
	print('-1')
	sys.exit()
if k3 <= k2:
	print('-1')
	sys.exit()
n = 0
for i in range(k2, k3):
	if s[i] == '|':
		n += 1
q = n + 4
print(q)


s = input()
errors = 0
symbols1 = {'[': 0, ':': 0, '|': 0}
start = 0
end = 0
for i in range(len(s)):
	if symbols1['['] == 0 and s[i] != '[':
		errors += 1
	elif symbols1['['] == 1 and symbols1[':'] == 0 and (s[i] != ':'):
		errors += 1
	elif symbols1['['] == 1 and symbols1[':'] == 1 and (s[i] != '|'):
		errors += 1
	else:
		symbols1[s[i]] += 1
		if symbols1['['] == 1 and symbols1[':'] == 1:
			start = i
			break
		elif symbols1['['] == 1:
			start_f = i
symbols = {':': 0, '|': 0, ']': 0}
for i in range(len(s) - 1, -1, -1):
	if symbols[']'] == 0 and s[i] != ']':
		errors += 1
	elif symbols[']'] == 1 and symbols[':'] == 0 and (s[i] != ':'):
		errors += 1
	elif symbols[']'] == 1 and symbols[':'] == 1 and (s[i] != '|'):
		errors += 1
	else:
		symbols[s[i]] += 1
		if symbols[':'] == 1 and symbols[']'] == 1:
			end = i
			break
		elif symbols[']'] == 1:
			end_f = i
for i in range(start + 1, end):
	if s[i] != '|':
		errors += 1
if symbols[':'] == 1 and symbols1[':'] == 1 and (symbols[']'] == 1) and (symbols1['['] == 1) and (start < end) and (start_f < end_f):
	print(len(s) - errors)
else:
	print(-1)


s = input()
b1 = s.find('[')
if b1 == -1:
	print(-1)
else:
	c1 = s.find(':', b1, len(s))
	b2 = s.rfind(']')
	if c1 == -1 or b2 == -1:
		print(-1)
	else:
		c2 = s.rfind(':', 0, b2)
		if c2 <= c1:
			print(-1)
		else:
			res = s.count('|', c1, c2)
			print(res + 4)


s = input()
(l, r) = (0, 0)
err = False
try:
	l = s.index('[')
	l = s.index(':', l + 1)
	r = s.rindex(']')
	r = s.rindex(':', l + 1, r)
except:
	print(-1)
else:
	print(s.count('|', l, r + 1) + 4)


s = input()
l = len(s)
a1 = s.find('[')
if a1 == -1:
	print(-1)
	exit()
a2 = s.find(':', a1 + 1)
if a2 == -1:
	print(-1)
	exit()
a3 = s.rfind(']')
if a3 == -1 or a3 <= a2:
	print(-1)
	exit()
a4 = s.rfind(':', 0, a3)
if a4 == -1 or a4 <= a2:
	print(-1)
	exit()
res = a1
res += l - a3 - 1
res += a2 - a1 - 1
res += a3 - a4 - 1
for i in range(a2 + 1, a4):
	if s[i] != '|':
		res += 1
print(l - res)