#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n;cin>>n;
  int ans=0;
  string s[3];cin>>s[0]>>s[1]>>s[2];
  rep(i,n){
    char c[3];
    rep(j,3)c[j]=s[j][i];
    sort(c,c+3);
    if(c[0]!=c[1])ans++;
    if(c[1]!=c[2])ans++;
  }
  cout<<ans<<endl;
  return 0;
}

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
using qp=queue<pair<int,int>>;
 
int main(){
  int H,W; 
  cin>>H>>W;
  
  string s;
  vector<string> S(H+2,string(W+2,'#'));
  int cnt=0;
  REP(h,H) {
    cin>>s;
    S[h+1]='#'+s+'#';
    for(auto x: S[h+1]) if(x=='.') cnt++;
  }
  int I[H+2][W+2]={};
  qp Q;
  Q.push(make_pair(1,1));
  I[1][1]=1;
  int h,w,nh,nw;
  int dh[4]={1, 0,-1, 0};
  int dw[4]={0, 1, 0,-1};
  while(!Q.empty()){
    h=Q.front().first;
    w=Q.front().second;
    Q.pop();
    REP(i,4){
      nh=h+dh[i];
      nw=w+dw[i];
      if(S[nh][nw]=='.'&&I[nh][nw]==0){
        Q.push(make_pair(nh,nw));
        I[nh][nw]=I[h][w]+1;
      }
    }
  }
  int ans=(I[H][W])? cnt-I[H][W]: -1;
  cout<<ans<<endl;   
}