#include <bits/stdc++.h>
using namespace std;
struct A {
  double a;
  long long anum;
  long long bnum;
  long long sum1;
  bool operator<(const A& rhs) const { return a < rhs.a; }
} B;
bool cmp(const A D, const A G) { return D.a > G.a; };
int main() {
  int n;
  scanf("%d", &n);
  string a;
  vector<A> D;
  for (int i = 0; i < n; i++) {
    cin >> a;
    long long ks1 = 0;
    long long ks2 = 0;
    long long sum = 0;
    for (int k = a.size() - 1; k >= 0; k--) {
      if (a[k] == 's') {
        ks1++;
        sum = sum + ks2;
      } else {
        ks2++;
      }
    }
    double d = ks1 / (ks2 * 1.0);
    B.a = d;
    B.anum = ks1;
    B.bnum = ks2;
    B.sum1 = sum;
    D.push_back(B);
  }
  sort(D.begin(), D.end(), cmp);
  long long ks1 = 0;
  long long ks2 = 0;
  long long SUMS = 0;
  for (int i = 0; i < D.size(); i++) {
    SUMS += D[i].sum1;
    SUMS += ks1 * D[i].bnum;
    ks1 += D[i].anum;
    ks2 += D[i].bnum;
  }
  cout << SUMS << endl;
  return 0;
}
