#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, m;
  scanf("%2d:%2d", &h, &m);
  int ans = 0;
  while (h % 10 != m / 10 || h / 10 != m % 10) {
    ++ans;
    ++m;
    h = (h + m / 60) % 24;
    m %= 60;
  }
  printf("%d\n", ans);
  while (getchar() != -1)
    ;
}
