program p1303;
var i,j,n,k,next,p:longint;
a,f,max:array[1..100]of longint;
s:string;
max0,min:longint;
begin
readln(s);
n:=1;
for i:=1 to length(s) do
if s[i]<>',' then a[n]:=a[n]*10+ord(s[i])-48
else inc(n);
for i:=1 to n do f[i]:=1;
for i:=2 to n do
for j:=1 to i-1 do
if a[i]<=a[j] then
if f[i]max0:=-1;
for i:=1 to n do if max0writeln(max0); {第一问就是求最长不升子序列,注意要遍历,因为不能保证f[n]最大}
end.