#include <bits/stdc++.h>
using namespace std;
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(int n, int pos) { return (bool)(n & (1 << pos)); }
long long bigmod(long long b, long long p, long long m) {
  if (p == 0) return 1;
  long long ret = bigmod(b, p / 2, m);
  ret = (ret * ret) % m;
  if (p & 1) ret = (ret * b) % m;
  return ret;
}
struct info {
  long long s, h;
  string str;
  info() {}
  info(string _str) {
    str = _str;
    s = h = 0;
    for (int i = 0; i < (int)str.size(); i++) {
      if (str[i] == 's')
        s++;
      else
        h++;
    }
  }
  bool operator<(const info &p) const {
    long long act = s * p.h;
    long long other = p.s * h;
    return (act > other);
  }
};
vector<info> v;
int main() {
  string str;
  int n, i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    cin >> str;
    v.push_back(info(str));
  }
  sort(v.begin(), v.end());
  long long ret = 0, s = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < v[i].str.size(); j++) {
      if (v[i].str[j] == 's')
        s++;
      else
        ret += s;
    }
  }
  printf("%lld", ret);
  printf("\n");
  return 0;
}
