#include <bits/stdc++.h>
using namespace std;
bool vowel(char a) {
  a = toupper(a);
  if ((a == 'A') || (a == 'E') || (a == 'I') || (a == 'O') || (a == 'U'))
    return 1;
  return 0;
}
long long int m, q, a, b, c, sum = 0, cnt = 0;
int n;
map<long long int, bool> mp;
string s;
struct my {
  long long int id, ss;
} arr[100005];
bool cmp(my a, my b) { return a.ss > b.ss; }
long long int cum[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
    a = 0, b = 0;
    int sz = s.size();
    for (int j = 0; j < sz; j++) {
      if (s[j] == 's') {
        a++;
      }
    }
    arr[i].id = i;
    arr[i].ss = (((a * 1.00) / (sz * 1.00)) * 100000);
  }
  sort(&arr[0], &arr[n], cmp);
  string s = "";
  for (int i = 0; i < n; i++) {
    s += v[arr[i].id];
  }
  a = 0;
  cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 's') a++;
    if (s[i] == 'h') cnt += a;
  }
  cout << cnt << endl;
}
