### constant

MAX_INT = 1 << 30

SCOSTS = [
  [[0, 1, 3, 3],  #0->0
   [1, 1, 2, 2],  #0->1
   [2, 2, 2, 2]], #0->2
  [[1, 1, 2, 2],  #1->0
   [0, 1, 1, 2],  #1->1
   [1, 2, 1, 2]], #1->2
  [[2, 2, 2, 2],  #2->0
   [1, 2, 1, 2],  #2->1
   [0, 3, 1, 3]]  #2->2
]

### main

tn = gets.strip.to_i

tn.times do
  n = gets.strip.to_i
  books = gets.strip.split('').map{|s| s == 'Y'}
  #p [n, books]

  n2 = n * 2
  n4 = n * 4

  costs = [0, MAX_INT, MAX_INT]

  for i in (0..n)
    pcosts = costs
    costs = []

    i2 = i * 2
    i2n2 = i2 + n2
    shelf = 0
    shelf |= 1 if i < n && books[i2]   || i > 0 && books[i2 - 1]
    shelf |= 2 if i < n && books[i2n2] || i > 0 && books[i2n2 - 1]
    #p shelf

    for to in (0..2)
      min_cost = MAX_INT
      for from in (0..2)
        cost = pcosts[from] + SCOSTS[from][to][shelf]
        min_cost = cost if min_cost > cost
      end
      costs[to] = min_cost
      costs[to] += 1 if i < n
    end
  end

  puts costs[0]
end