#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0; i < (n); i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if(a > b) a = b; }
template<typename A, typename B> inline void chmax(A &a, B b) { if(a < b) a = b; }

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}

string s;

int64 om[212345][2], am[212345][2], term_m[212345][2];
int64 om_s[212345][2], am_s[212345][2], term_m_s[212345][2];
int64 or_exp(const string&, int64&, int64);
int64 and_exp(const string&, int64&, int64);
int64 term(const string&, int64&, int64);

int64 formula(const string& s, int64& p, int64 tar) {
    return or_exp(s, p, tar);
}

int64 or_exp(const string& s, int64& p, int64 tar) {
    if (~om[p][tar]) {
        int64 q = p;
        p = om_s[p][tar];
        return om[q][tar];
    }
    int64 q = p;
    int64 &ret = om[p][tar], &rs = om_s[p][tar];
    ret = and_exp(s, p, tar);
//    cout << "or " << p << " " << q << ": " << endl;
    p = q;
//    cout << "or (" << p << " " << q << ") " << endl;
    int64 sum = and_exp(s, p, 1-tar);
//    cout << "or (" << p << " " << q << ") " << endl;
    while (p < s.size() && s[p] == '|') {
        p++;
        if (tar == 0) {
            ret += and_exp(s, p, tar);
        } else {
            q = p;
            chmin(ret, sum + and_exp(s, p, tar));
            p = q;
            sum += and_exp(s, p, 1-tar);
        }
    }
//    cout << "or " << p << " " << tar << " " << ret << endl;
    rs = p;
    return ret;
}

int64 and_exp(const string& s, int64& p, int64 tar) {
    if (~am[p][tar]) {
        int64 q = p;
        p = am_s[p][tar];
        return am[q][tar];
    }
    int64 &ret = am[p][tar], &rs = am_s[p][tar];
    int64 q = p;
    ret = term(s, p, tar);
    p = q;
    int64 sum = term(s, p, 1-tar);
//    cout << "and (" << q << " " << p << ") " << endl;
    while (p < s.size() && s[p] == '&') {
        p++;
        if (tar == 1) {
            ret += term(s, p, tar);
        } else {
            q = p;
            chmin(ret, sum + term(s, p, tar));
            p = q;
            sum += term(s, p, 1-tar);
        }
    }
    rs = p;
    return ret;
}

int64 term(const string& s, int64& p, int64 tar) {
    if (~term_m[p][tar]) {
        int64 q = p;
        p = term_m_s[p][tar];
        return term_m[q][tar];
    }
    int64& ret = term_m[p][tar], &rs = term_m_s[p][tar];
    if (s[p] == '(') {
        p++;
        ret = or_exp(s, p, tar);
        p++;
    } else {
        p++;
        ret = 1;
    }
    rs = p;
//    cout << "term " << p << " " << tar << " " << ret << endl;
    return ret;
}

int main(void) {
    memset(om, -1, sizeof om);
    memset(am, -1, sizeof am);
    memset(term_m, -1, sizeof term_m);
    cin >> s;
    REP(i, 2) {
        int64 p = 0;
        cout << formula(s, p, i) << (i == 0 ? " " : "");
    }

    cout << endl;
}


Measured memory_bytes: 22684