#include <bits/stdc++.h>
char a[10];
int main() {
  scanf("%s", a);
  int curhour = (a[0] - '0') * 10 + (a[1] - '0');
  int inithour = curhour;
  int curmin = (a[3] - '0') * 10 + (a[4] - '0');
  int tmp = (a[1] - '0') * 10 + (a[0] - '0');
  if (curmin <= tmp && tmp < 60) {
    printf("%d", tmp - curmin);
  } else {
    curhour = (curhour + 1) % 24;
    int p = curhour / 10;
    int q = curhour % 10;
    int newhour = 10 * q + p;
    if (newhour >= 60) {
      while (newhour >= 60) {
        curhour = (curhour + 1) % 24;
        p = curhour / 10;
        q = curhour % 10;
        newhour = 10 * q + p;
      }
      printf("%d", (curhour - inithour - 1) * 60 + (60 - curmin) + newhour);
    } else
      printf("%d", newhour + 60 - curmin);
  }
  return 0;
}
