#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (auto &v : a) {
    cin >> v;
  }
  auto f = [](string s) -> long long {
    long long cnts = 0;
    long long res = 0;
    for (char ch : s) {
      if (ch == 's')
        cnts++;
      else
        res += cnts;
    }
    return res;
  };
  sort(a.begin(), a.end(),
       [&](string a, string b) { return f(a + b) > f(b + a); });
  string s = "";
  for (auto &v : a) s += v;
  cout << f(s);
  return 0;
}
