#include <bits/stdc++.h>
using namespace std;
int main()
{
int T, n, ans = 0;
cin >> T;
while (T--) {
string s, t;
ans = 0;
cin >> n >> s >> t;
for (int i = 0; i < n; ) {
for (int j = t.find(s[i]); j < n; j++, i++) {
if (s[i] != t[j]) {
ans++;
break;
}
}
}
cout << ans << endl;
}
return 0;
}