#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#include <climits>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
 
    int n;
    cin >> n;
    vector<string> s(n);
 
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    string maxi = s[0];
    for (int i = 1; i < n; i++) {
        int j = 0;
        while (j <maxi.size()&&j<s[i].size()&&maxi[j]== s[i][j]) {
            j++;
        }
        maxi =maxi.substr(0, j); 
 
    }
 
 
    int op = 0;
    for (int i = 0; i < n; i++) {
        op+= (s[i].size() -maxi.size());
    }
 
    cout << op<< endl;
    return 0;
}