#include<stdio.h>
#include <stdlib.h>
#include<string.h>

int main() {
  int n;
  scanf("%d\n", n);
  int a[n];
  scanf("%d\n", a);
  int n2 = n - 1;
  int i = 1;
  int x;
  while(n2--){
    scanf("%d\n", a++);
    x = strcmp(a[i], a[i+1]);
    if(x)
      sum += x;
  }
  printf("%d\n", sum);
  return 0;
}
