#include <bits/stdc++.h>
using namespace std;
long long check(const string &s) {
  long long res = 0, x = 0;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 's') {
      x++;
    } else {
      res += x;
    }
  }
  return res;
}
bool cmp(const string &s1, const string &s2) {
  return check(s1 + s2) > check(s2 + s1);
}
int32_t main() {
  long long n;
  cin >> n;
  vector<string> num(n);
  for (long long i = 0; i < n; i++) cin >> num[i];
  sort(num.begin(), num.end(), cmp);
  string res = "";
  for (long long i = 0; i < n; i++) res += num[i];
  cout << check(res) << "\n";
  return 0;
}
