#include <bits/stdc++.h>
int main() {
  int h, m, ans = 0;
  scanf("%d:%d", &h, &m);
  while (h != (m / 10 + m % 10 * 10)) {
    m++;
    ans++;
    if (m == 60) {
      h++;
      m = 0;
    }
    if (h == 24) h = 0;
  }
  printf("%d", ans);
}
