#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159265;
const long long mod = 998244353;
const long long MOD = 1000000007;
const long long INF = 0x7f7f7f7f7f7f7f7f;
long long add(long long x, long long y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += MOD;
  return x;
}
long long mul(long long x, long long y) { return (x * y * 1ll) % MOD; }
long long powr(long long a, long long b) {
  long long x = 1 % MOD;
  while (b) {
    if (b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
long long modinv(long long x) { return powr(x, MOD - 2); }
long long dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
const long long N = 1000001;
void solve() {
  string s;
  long long n, x;
  cin >> n >> s;
  long long ans = 0, res = 0;
  res = 1;
  for (long long i = 1; i < n; i++) {
    if (s[i] != s[i - 1])
      res++;
    else
      ans++, ans = min(ans, res);
  }
  ans = (ans + res + 1) / 2;
  cout << ans << "\n";
}
int32_t main() {
  long long test = 1;
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> test;
  cout << fixed;
  cout << setprecision(6);
  for (long long testcase = 1; testcase < test + 1; testcase++) {
    solve();
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
