#include <bits/stdc++.h>
using namespace std;
const int N = 20000;
mt19937 gen(time(NULL));
template <typename T = int>
inline T read() {
  T val = 0, sign = 1;
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') sign = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) val = val * 10 + ch - '0';
  return sign * val;
}
void solve() {
  int n;
  cin >> n;
  vector<string> a(n);
  for (auto &v : a) cin >> v;
  auto f = [](string s) -> long long {
    long long total = 0;
    int open = 0;
    for (char c : s)
      if (c == 's')
        open++;
      else
        total += open;
    return total;
  };
  sort((a).begin(), (a).end(),
       [&](string s, string t) { return f(s + t) > f(t + s); });
  string s = "";
  for (auto v : a) s += v;
  cout << f(s) << '\n';
}
signed main() {
  int t = 1;
  while (t--) {
    clock_t z = clock();
    solve();
    fprintf(stderr, "Total Time: %.3f\n",
            (double)(clock() - z) / CLOCKS_PER_SEC),
        fflush(stderr);
  }
}
