#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class myClass {
 private:
 public:
  string str;
  ll sCount;
  ll hCount;
  ll selfValue;
  myClass(string s) {
    str = s;
    sCount = 0LL;
    hCount = 0LL;
    selfValue = 0LL;
    for (int i = 0; i < s.length(); i++)
      if (s[i] == 's') {
        sCount++;
      } else {
        hCount++;
        selfValue += sCount;
      }
  }
  void show() const { cout << str << " "; }
};
int main() {
  int n;
  cin >> n;
  vector<myClass> vec;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    myClass myObj(str);
    vec.push_back(myObj);
  }
  sort(vec.begin(), vec.end(), [](myClass o1, myClass o2) -> bool {
    return o1.sCount * o2.hCount > o2.sCount * o1.hCount;
  });
  ll ans = 0LL;
  ll sCount = 0LL;
  for (vector<myClass>::iterator it = vec.begin(); it != vec.end(); it++) {
    ans += sCount * (it->hCount) + (it->selfValue);
    sCount += (it->sCount);
  }
  cout << ans << endl;
  return 0;
}
