#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1, M = 1e2 + 1, INF = 2e9, MOD = 1e9 + 7, L = 20,
                NN = 1e9 + 1;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long i = 0;
  long long ans = 0;
  long long j = i;
  while (i < n) {
    ans++;
    if (j < i) j = i;
    while (j < n - 1 && s[j] != s[j + 1]) j++;
    if (j + 1 < n && s[j] == s[j + 1])
      j++;
    else {
      char c = s[i];
      while (i < n && s[i] == c) i++;
    }
    if (i == n) break;
    char c = s[i];
    while (i < n && s[i] == c) i++;
  }
  cout << ans << '\n';
}
signed main() {
  long long t = 1;
  cin >> t;
  while (t--) solve();
}
