#include <bits/stdc++.h>
using namespace std;
string h, sec, s, check;
bool flag = 0;
int minutes, counter = 0, hours;
int main() {
  scanf("%d:%d", &hours, &minutes);
  while (1) {
    if ((hours / 10 == minutes % 10) && (hours % 10 == minutes / 10)) {
      cout << counter;
      break;
    }
    minutes++;
    counter++;
    if (minutes == 60) {
      minutes = 0;
      hours++;
      if (hours == 24) hours = 0;
    }
  }
  return 0;
}
