#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> s; vector> cnt(3,vector(3,0)); rep(i,n*3){ rep(j,3){ if(s[i]==t[j]) cnt[i%3][j]++; } } vector ans(3,1001001); rep(i,3){ rep(j,3){ chmin(ans[i], cnt[(i+j)%3][j]); } } if(ans[0]==n){ cout << n << '\n'; }else{ cout << min(ans[0]+ans[1]+ans[2], n-1) << '\n'; } return 0; }