#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  while (cin >> input) {
    int hour, minute;
    hour = (input[0] - 48) * 10 + (input[1] - 48);
    minute = (input[3] - 48) * 10 + (input[4] - 48);
    int judge = 0, count = 0;
    while (!judge) {
      int temp1, temp2;
      temp1 = minute / 10;
      temp2 = minute % 10;
      if ((temp1 + temp2 * 10) == hour)
        judge = 1;
      else {
        count++;
        if (minute + 1 == 60) {
          minute = 0;
          if (hour + 1 == 24) {
            hour = 0;
          } else
            hour += 1;
        } else {
          minute++;
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
