#include <bits/stdc++.h>
using namespace std;
vector<string> v;
long long calc(string q) {
  long long ans = 0, s = 0;
  for (int i = 0; i <= q.length() - 1; i++) {
    if (q[i] == 's')
      s++;
    else
      ans += s;
  }
  return ans;
}
inline bool cmp(string s1, string s2) {
  long long ab = calc(s1 + s2), ba = calc(s2 + s1);
  return ab > ba;
}
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  sort(v.begin(), v.end(), cmp);
  string s = "";
  for (int i = 0; i <= v.size() - 1; i++) {
    s += v[i];
  }
  cout << calc(s);
}
