#include <bits/stdc++.h>
using namespace std;
struct seg {
  long long cs, ch, i;
};
bool comp(seg a, seg b) { return a.cs * b.ch > a.ch * b.cs; }
void solve() {
  long long n;
  cin >> n;
  long long i;
  vector<string> v;
  string s;
  vector<seg> p;
  for (i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
    long long cs = 0, ch = 0;
    long long j;
    for (j = 0; j < s.length(); j++) {
      cs += (s[j] == 's');
      ch += (s[j] == 'h');
    }
    seg temp;
    temp.cs = cs;
    temp.ch = ch;
    temp.i = i;
    p.push_back(temp);
  }
  sort((p).begin(), (p).end(), comp);
  long long nos = 0;
  long long res = 0;
  for (auto it : p) {
    long long ind = it.i;
    for (i = 0; i < v[ind].length(); i++) {
      nos += (v[ind][i] == 's');
      if (v[ind][i] == 'h') {
        res += nos;
      }
    }
  }
  cout << res << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  cout << setprecision(20);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
