#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, Max = 5e6 + 10, inf = 1e9;
string s[maxn];
int nxt[Max][2], val[Max], C;
int ln;
int LZ;
void add(string &s, int x) {
  x -= LZ;
  int tmp = 0;
  for (char ch : s) {
    val[tmp] = min(val[tmp], x);
    if (nxt[tmp][ch - '0'] == 0) nxt[tmp][ch - '0'] = ++C, val[C] = x;
    tmp = nxt[tmp][ch - '0'];
  }
  val[tmp] = min(val[tmp], x);
}
int ask(string &s) {
  int tmp = 0;
  for (char ch : s) {
    tmp = nxt[tmp][ch - '0'];
    if (tmp == 0) return inf;
  }
  return val[tmp] + LZ;
}
int f(string &a, string &b) {
  for (int i = ln; i > 0; i--) {
    if (a.substr(ln - i) == b.substr(0, i)) return i;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie();
  val[0] = inf;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  ln = int((s[0]).size());
  int all = ln;
  for (int i = n - 2; i >= 0; i--) {
    string str;
    int num = all + ln;
    for (int j = 0; j <= ln; j++) {
      num = min(num, ln - j + ask(str));
      if (j != ln) str = s[i][ln - j - 1] + str;
    }
    LZ += ln - f(s[i], s[i + 1]);
    add(s[i + 1], num);
    all += ln - f(s[i], s[i + 1]);
  }
  return cout << min(all, val[0] + LZ) << endl, 0;
}
