#include <bits/stdc++.h>
using namespace std;
int n, len;
long long sum, result;
struct xvlie {
  long long s, h;
  string str;
} ar[100005];
bool cmp(const xvlie &a, const xvlie &b) { return a.s * b.h > a.h * b.s; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    cin >> ar[i].str;
    len = ar[i].str.length();
    for (int j = 0; j < len; j++) {
      if (ar[i].str[j] == 's') ar[i].s++;
      if (ar[i].str[j] == 'h') ar[i].h++;
    }
  }
  sort(ar + 1, ar + 1 + n, cmp);
  for (int i = 2; i <= n; i++) ar[1].str += ar[i].str;
  len = ar[1].str.length();
  for (int i = 0; i < len; i++) {
    if (ar[1].str[i] == 's') sum++;
    if (ar[1].str[i] == 'h') result += sum;
  }
  cout << result << endl;
  return 0;
}
