#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n = 0;
    cin >> n;
    vector<char> a(n);
    for (int j = 0; j < n; ++j) {
      cin >> a[j];
    }
    int caunt = 0;
    int l = 0;
    int r = 0;
    int m = 0;
    for (int j = 0; j < n; ++j) {
      if (a[j] == '<') l++;
      if (a[j] == '>') r++;
      if (a[j] == '-') m++;
      if (j + 1 < n) {
        if (a[j] == '<' && a[j + 1] == '>') caunt++;
        if (a[j] == '>' && a[j + 1] == '<') caunt++;
        if (a[j] == '<' && a[j + 1] == '<') caunt++;
        if (a[j] == '>' && a[j + 1] == '>') caunt++;
      } else {
        if (a[j] == '<' && a[0] == '>') caunt++;
        if (a[j] == '>' && a[0] == '<') caunt++;
        if (a[j] == '<' && a[0] == '<') caunt++;
        if (a[j] == '>' && a[0] == '>') caunt++;
      }
    }
    if (n == l + m || n == r + m) {
      cout << n << "\n";
    } else {
      cout << n - caunt << "\n";
    }
  }
  return 0;
}
