#include <bits/stdc++.h>
using namespace std;
struct info {
  double val;
  string a;
};
vector<info> t;
int n, x, y, hcnt, sumh;
double aa;
long long res = 0;
bool cmp(const info &u, const info &v) { return u.val > v.val; }
int main() {
  string a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    x = y = 0;
    cin >> a;
    for (int j = 0; a[j]; j++)
      if (a[j] == 's')
        x++;
      else if (a[j] == 'h')
        y++;
    sumh += y;
    if (y == 0)
      aa = 2e9;
    else
      aa = (double)x / y;
    t.push_back({aa, a});
  }
  sort(t.begin(), t.end(), cmp);
  int Size = t.size();
  for (int i = 0; i < Size; i++) {
    int sSize = t[i].a.size();
    for (int j = 0; j < sSize; j++) {
      if (t[i].a[j] == 'h')
        sumh--;
      else if (t[i].a[j] == 's')
        res += sumh;
    }
  }
  cout << res;
  return 0;
}
