#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 60) - 1;
const int64 infll2 = (1LL << 58) - 1;
const int inf = (1 << 30) - 1;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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 V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

const int OR = 0;
const int AND = 1;
const int QUESTION = 3;

map< int, int > dp[2];
int latte = 2;

struct Node {
  int type;
  int id;
  vector< Node * > child;

  Node(int t) : type(t), id(latte++) {}


  int dfs(int v) {
    if(dp[v].count(id)) {
      return dp[v][id];
    }
    int ret = inf;

    if(type == OR) {
      if(v == 1) {
        int add = 0;
        for(auto &t : child) {
          chmin(ret, t->dfs(v) + add);
          add += min(t->dfs(0), t->dfs(1));
        }
      } else {
        ret = 0;
        for(auto &t : child) {
          ret += t->dfs(v);
        }
      }
    } else if(type == AND) {
      if(v == 1) {
        ret = 0;
        for(auto &t : child) {
          ret += t->dfs(v);
        }
      } else {
        int add = 0;
        for(auto &t : child) {
          chmin(ret, t->dfs(v) + add);
          add += min(t->dfs(0), t->dfs(1));
        }
      }
    } else if(type == QUESTION) {
      ret = 1;
    } else {
      assert(0);
    }
    return dp[v][id] = ret;
  }
};

string S;
int ptr;

Node *or_expr();

Node *term() {
  if(S[ptr] == '?') {
    Node *cur = new Node(QUESTION);
    ++ptr;
    return cur;
  } else if(S[ptr] == '(') {
    ++ptr;
    auto ret = or_expr();
    ++ptr;
    return ret;
  } else {
    assert(0);
  }
}

Node *and_expr() {
  Node *cur = new Node(AND);
  cur->child.emplace_back(term());
  while(S[ptr] == '&') {
    ++ptr;
    cur->child.emplace_back(term());
  }
  return cur;
}

Node *or_expr() {
  Node *cur = new Node(OR);
  cur->child.emplace_back(and_expr());
  while(S[ptr] == '|') {
    ++ptr;
    cur->child.emplace_back(and_expr());
  }
  return cur;
}


void ushitapunichiakun(string arg) {
  cin >> S;
  S += "$";
  auto root = or_expr();
  cout << root->dfs(0) << " " << root->dfs(1) << endl;
}

int main() {
  ushitapunichiakun("笑");
}


Measured memory_bytes: 28232