------
## 最终结论
```python
def max_operations(t, test_cases):
    results = []
    
    for case in test_cases:
        n, s = case
        count = 0
        
        # Count the number of transitions from '0' to '1' or '1' to '0'
        for i in range(1, n):
            if s[i] != s[i - 1]:
                count += 1
        
        # The number of operations is the number of transitions + 1 (for the last segment)
        results.append(count + 1)
    
    return results

# Input reading
t = int(input())
test_cases = []
for _ in range(t):
    n = int(input())
    s = input().strip()
    test_cases.append((n, s))

# Get results
results = max_operations(t, test_cases)

# Output results
for result in results:
    print(result)
```