#include <bits/stdc++.h>
using namespace std;
struct node {
  string str;
  float cnt;
};
node a[100010];
int n, s, h;
long long ans;
bool cmp(node a, node b) { return a.cnt < b.cnt; }
int main() {
  while (cin >> n) {
    ans = 0;
    for (int i = 0; i < n; i++) cin >> a[i].str;
    for (int i = 0; i < n; i++) {
      s = 0;
      h = 0;
      int len = a[i].str.length();
      for (int j = 0; j < len; j++) {
        char c = a[i].str[j];
        if (c == 's')
          s++;
        else
          h++;
      }
      if (s != 0)
        a[i].cnt = (float)h / s;
      else
        a[i].cnt = 10000001;
    }
    sort(a, a + n, cmp);
    s = 0;
    for (int i = 0; i < n; i++) {
      int len = a[i].str.length();
      for (int j = 0; j < len; j++) {
        char c = a[i].str[j];
        if (c == 's')
          s++;
        else
          ans += s;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
