#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
pair<long long, long long> and_expr(State &a);
pair<long long, long long> term(State &a);
pair<long long, long long> or_expr(State &a) {
	pair<long long, long long> ans = and_expr(a);
	while (*a != '!') {
		if (*a == '|') {
			a++;
			pair<long long, long long> now = or_expr(a);
			pair<long long, long long> next_go = make_pair(0, 0);
			//if 0 - 0
			next_go.first = ans.first + now.first;
			//if 1 - ? or 0 - 1
			next_go.second = min(ans.second, ans.first + now.second);
			ans = next_go;
		}
		else {
			break;
		}
	}
	return ans;
}
pair<long long, long long> and_expr(State &a) {
	pair<long long, long long> ans = term(a);
	while (*a != '!') {
		if (*a == '&') {
			a++;
			pair<long long, long long> now = and_expr(a);
			pair<long long, long long> next_go = make_pair(0, 0);
			//0 - ? or 1 - 0
			next_go.first = ans.first;
			next_go.first = min(next_go.first, ans.second + now.first);
			//1 - 1 is only time to be '1'
			next_go.second = ans.second + now.second;
			ans = next_go;
		}
		else {
			break;
		}
	}
	return ans;
}
pair<long long, long long> term(State &a) {
	if (*a == '(') {
		a++;
		pair<int,int> now = or_expr(a);
		a++;
		return now;
	}
	else if (*a == '?') {
		a++;
		return make_pair(1, 1);
	}
}
int main() {
	string s;
	cin >> s;
	s.push_back('!');
	State hoge = s.begin();
	pair<int, int> ans = or_expr(hoge);
	cout << ans.first << " " << ans.second << endl;
	return 0;
}
