#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int a[MAXN], b[MAXN], same[MAXN], n;
void init(std::string A, std::string B)
{
n = A.size();
a[1] = (A[0] == 'A'), b[1] = (B[0] == 'A');
same[1] = (A[0] == B[0]);
for (int i = 2; i <= n; i++)
{
a[i] = a[i - 1] + (A[i - 1] == 'A');
b[i] = b[i - 1] + (B[i - 1] == 'A');
same[i] = same[i - 1] + (A[i - 1] == B[i - 1]);
}
}
int get_distance(int x, int y)
{
x++, y++;
if (a[y] - a[x - 1] != b[y] - b[x - 1])
return -1;
return ((y - x + 1) - (same[y] - same[x - 1])) / 2;
}