import bisect
# 最长严格上升子序列长度
def get_lis_len(arr):
lst = []
for i in range(len(arr)):
idx = bisect.bisect_left(lst, arr[i])
if idx >= 0 and idx < len(lst):
lst[idx] = arr[i]
else:
lst.append(arr[i])
return len(lst)
# 最长非严格上升子序列长度
def get_lis_eq_len(arr):
lst = []
for i in range(len(arr)):
idx = bisect.bisect_right(lst, arr[i])
if idx >= 0 and idx < len(lst):
lst[idx] = arr[i]
else:
lst.append(arr[i])
return len(lst)
arr = list( map(int, input().split()) )
# 第一问求的是逆序序列中非严格上升的LIS长度
print(get_lis_eq_len( list(reversed(arr)) ))
# 第二问等价于求正序的严格LIS长度
print(get_lis_len(arr))