#include <bits/stdc++.h>
const double PI = 3.141592653589793238;
using namespace std;
long long takeTurn(long long n) {
  if (n % 2 == 1) return n - 1;
  if (n % 4 == 0 && n > 4) return n - 1;
  return n / 2;
}
void solve() {
  long long n, res = 0;
  cin >> n;
  while (n > 0) {
    long long t1 = takeTurn(n);
    res += n - t1;
    n = t1;
    n = takeTurn(n);
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
